-
Notifications
You must be signed in to change notification settings - Fork 57
Refactor CLI, group flags, add aliases and support for env variables #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
derive feature of clapderive feature of clap
41a033a to
8a6b118
Compare
derive feature of clapdb38116 to
216dcad
Compare
216dcad to
bf61e49
Compare
…, add backward-compatible aliases
Grouping means that only one of the flags can be set at the same time. `clap` will throw an error otherwise
6b73dae to
17ec92f
Compare
micprog
left a comment
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.
Thanks for the additions! I really like the new format and what it enables in code cleanliness, as well as the predefined environment variables for certain flags. I haven't gone through the script.rs file yet, but here is some initial feedback.
|
The script command looks OK at first glance, I think testing through usage will reveal any issues here. The CLI regression tests failures also look as expected. |
The default of `clap` is to set the `bool` to `false` so specifying this action doesn't do anything expect making the derive macro longer
|
Thanks for the review and catching some errors that I missed! I should have addressed all of your comments. There are currently three CLI tests failing which is expected: Those are "new" argument names that didn't exist before (but with backward compatible aliases that are also checked with in the The one that I don't really know what to do about is the |
micprog
left a comment
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.
LGTM, thanks!
CLI refactor
derivefeatureSince a while
clapsupports declaritive structs instead of a runtime builder, which is now the recommended way to build CLIs. It is easier to read, and modify and the resulting implementation is very clean in my opinion. Especially when it comes to subcommands which are represented as enums in Rust.CLI organisation
I reorganized all the CLI subcommands and flags, in a way that should still be backwards compatible:
bender script <target>are now implemented as nested subcommands ofscript. This change is mainly reflected when calling the help page ofscript.script.rs. Examples are--vlog-arg,--vcom-argand--only-*. Now, they are moved/duplicated into each target that uses them which automatically takes care of these checks.--only-*flags are grouped, meaningclapwill automatically return an error if multiple one of them are specified at the same time. The same goes forpackages --graph, that does not allow--versionand/or--targets--vlog-argwas used by all targets for general verilog arguments even though the underlying executable has a different name. Now, the flag is called--vlogan-argfor VCS, but backward compatibility is ensured with aliases to--vlog-arg.bender script <target> --help).--vlog-args/--vlog-argboth work now orparents/parentas well.Environment variables
Global flags (e.g. git throttle, local, dir etc., ) can now also be provided as environment variables. The help pages also reflect this. The precedence is flag > environment variable > default.
TODOs:
bender script <target>could be implemented as subsubcommands with enums instead of strings if possible)$[arg(long = <field-but-dashed>, short = <first-letter-of-field>]deprecatemodify previous--vcom-argsetc., in favor of tool-specific args(with graceful deprecation warning in the beginning)with aliases to keep backward compabilityenvfeature ofclapto set flags based on environment variables (and deprecate config?)Decide how/whether to mergemoved to CLI regression tests #245cli_regressiontest suitelower_casei.e.vendorhad some.