Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Better command line argument handling #3628#4597

Closed
demon1999 wants to merge 14 commits intoethereum:developfrom
demon1999:develop
Closed

Better command line argument handling #3628#4597
demon1999 wants to merge 14 commits intoethereum:developfrom
demon1999:develop

Conversation

@demon1999
Copy link
Contributor

@demon1999 demon1999 commented Oct 12, 2017

Resolves #3628

@gumb0
Copy link
Member

gumb0 commented Oct 13, 2017

Thanks a lot for your work! I'll try to look at it next week.

You could rebase it on the latest develop and resolve conflicts meanwhile.

@gumb0 gumb0 requested review from chfast and gumb0 October 13, 2017 17:18
@pirapira
Copy link
Member

@demon1999 are you still around?

@demon1999
Copy link
Contributor Author

Yes, I am. Now I'm reading about rebase.

@chfast
Copy link
Member

chfast commented Oct 18, 2017

@demon1999 it would be better to split this PR into smaller parts. Can you make one that adds only boost program_options first. Then a PR that converts options for one of the smaller tools like rlp or ethvm.

@winsvega
Copy link

right. it is better to be done module by module. Id like to test testeth options first.

@demon1999
Copy link
Contributor Author

Ок, I'll do it when I'll have time.

@chfast
Copy link
Member

chfast commented Oct 19, 2017

Hi again.
Please also see #4613.
They are proposed changes to ethvm command line interface, so we might want to do them the same time.

#include <libdevcore/FileSystem.h>
#include <libdevcore/CommonIO.h>
#include <libethcore/KeyManager.h>
#include <boost/program_options.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these includes needed? Only includes are added to this file and nothing else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, I don't need it.

eth/main.cpp Outdated
("private", po::value<string>(), "<name> Use a private chain.")
("test", "Testing mode: Disable PoW and provide test rpc interface.")
("config", po::value<string>(), "<file> Configure specialised blockchain using given JSON information.")
("oppose-dao-fork", "Ignore DAO hard fork (default is to participate).\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and -f options are not supported anymore.
Probably there're more outdated options, I'll take a closer look later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

eth/main.cpp Outdated
("address,a", po::value<string>(), "<addr> Set the author (mining payout) address to given address (default: auto).")
("author", po::value<string>(), "<addr> Set the author (mining payout) address to given address (default: auto).")
("mining,m", po::value<string>(), "<on/off/number> Enable mining, optionally for a specified number of blocks (default: off).")
("force-mining,f", "Mine even when there are no transactions to mine (default: off).")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this 4 options?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only -f & --force-mining
mining itself is still supported

eth/main.cpp Outdated
clientDefaultMode.add_options()
("format", po::value<string>(), "<format> Set format.")
("script", po::value<string>(), "<script> Add script.")
("mainnet", "Use the main network protocol.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some lines are indented with spaces, please change to tabs everywhere


add_executable(main rlp/main.cpp)

add_executable(peer test/unittests/libp2p/peer.cpp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

("verbosity,v", po::value<string>(), "<0 - 9> Set the log verbosity from 0 to 9 (default: 8).")
("version,V", "Show the version and exit.")
("help,h", "Show this help message and exit.")
;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting looks weird in our style, please leave semicolon on the last line of the statement.


po::options_description generalOptions("General Options");
generalOptions.add_options()
("verbosity,v", po::value<string>(), "<0 - 9> Set the log verbosity from 0 to 9 (default: 8).")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we make it po::value<int> ?


namespace po = boost::program_options;

void help()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this function?

help();
else if (arg == "-V" || arg == "--version")
version();
else if (((arg == "-v" || arg == "--verbosity") && i + 1 < argc) || arg == "-h" || arg == "--help" || arg == "-V" || arg == "--version") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opening brace should be on a separate line

else if (arg == "-V" || arg == "--version")
version();
else if (((arg == "-v" || arg == "--verbosity") && i + 1 < argc) || arg == "-h" || arg == "--help" || arg == "-V" || arg == "--version") {
argv[ac] = argv[i];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what are you trying to achieve in this part?
I don't think assiging to argv is a very good idea

I think you're trying to get rid of all the options that are handled in KeyCLI::interpretOption() and leave only -v, -V, -h in argv
Why do you need this? Wouldn't po::store(po::parse_command_line(ac, argv, generalOptions), vm); below just ignore options not listed in generalOptions ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demon1999
Copy link
Contributor Author

#4635

@gumb0
Copy link
Member

gumb0 commented Oct 30, 2017

@demon1999 Are you still planning to update this PR or should we close this one and you will proceed with several smaller PRs?

@demon1999
Copy link
Contributor Author

You should close it. One of small pr's is 4635

@gumb0 gumb0 closed this Oct 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants