-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Refactoring the cli #11702
base: master
Are you sure you want to change the base?
Refactoring the cli #11702
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run this I see a the argument list divided into FLAGS
and OPTIONS
where before this was not the case. I don't think that was intentional but I'm not sure what the plan is there: can you elaborate?
The list of flags/options does not contain the helpful "labels" we used to have, e.g.:
Snapshot Options:
--no-periodic-snapshot
Disable automated snapshots which usually occur once every 5000 blocks.
--snapshot-threads=[NUM]
Enables multiple threads for snapshots creation.
…are now printed as separate items far apart in the long list of options. Not sure how capable structopt
is at grouping options together but I think it'd be important that we keep that.
parity/cli/subcommands.rs
Outdated
)] | ||
// FIXME: The original parser implementation had this as `Option<Vec<String>>` but this is not | ||
// supported by structopt yet, referring to issue | ||
// [#364](https://github.com/TeXitoi/structopt/issues/364) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's not quite how I read #364 – it seems to be quirky but not unsupported. Can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty awkward to distinguish in the CLI flag setting regardless so I'd treat empty list as None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the empty list was treated equivalently to None
in the previous version, and it's the same in this version. All the previous tests are passing, so unless this was a case not tested, we are good
parity/cli/subcommands.rs
Outdated
help = "Take a snapshot at the given block, which may be an index, hash, or latest. Note that taking snapshots at non-recent blocks will only work with --pruning archive" | ||
)] | ||
pub at: String, | ||
// FIXME: check if the default is correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you mean "default"? I don't think this should have a default (and it's required).
@@ -241,10 +241,5 @@ pub fn start<Cr, Rr>( | |||
Cr: Fn(String) + 'static + Send, | |||
Rr: Fn() + 'static + Send | |||
{ | |||
let deprecated = find_deprecated(&conf.args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is does deprecation work in this new version? It'd be good to have some internal documentation on how to best add/deprecate/remove cli flags/options/subcommands somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. I'm currently digging the CLI story a bit deeper, and this PR with a few modifications may actually become mergeable short-term.
term_size = "0.3" | ||
textwrap = "0.11.0" | ||
toml = "0.5.6" | ||
rust-embed = "5.5.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any strong reason not to use standard include
family macros?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just found rust-embed to have a cleaner api. I believe internally, it expands to include
macros
parity/cli/subcommands.rs
Outdated
)] | ||
// FIXME: The original parser implementation had this as `Option<Vec<String>>` but this is not | ||
// supported by structopt yet, referring to issue | ||
// [#364](https://github.com/TeXitoi/structopt/issues/364) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty awkward to distinguish in the CLI flag setting regardless so I'd treat empty list as None
.
There are a few edge cases that are worth mentioning (will keep editing this comment with further findings):
|
Not 100% sure I understand what you mean here. What is a "default config that the user is using"? and what is an "instance" in this context? Do you mean that a user has prepared a config "template" of sorts that they use for several nodes and wish to override just a few option for one particular node instance? Can't they just |
So essentially this version comes with a built in config generator flag that stores current flags into a file for future use - the assumption being people's configuration needs remain the same a majority of the time. However, once of twice, they may want to run a different config with a few altered flags - the usual way to do this is to just use their saved config and override flags, which is when this case arises. The user cannot |
That is pretty surprising (not a good thing when it comes to UX). I think the user expectation is that the CLI should work (very) similarly to how it worked before and any deviation from that should be a clear improvement. New users will likely expect the openethereum CLI to work like most other command line tools, where At this point I am not sure I understand what the idea is with this PR. Perhaps now is a good time to step back and write up a proper description on what the plan is, and how the CLI UI will work? |
This PR refactors the cli macros with
structopt
and adds an inbuilt configuration generator that can save the current flags into a custom toml for future use.