-
Notifications
You must be signed in to change notification settings - Fork 54
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
Draft
fischeti
wants to merge
33
commits into
master
Choose a base branch
from
fischeti/cli-derive
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
derive feature of clapderive feature of clap
430cc9e to
5f1b355
Compare
…, add backward-compatible aliases
41a033a to
8a6b118
Compare
derive feature of clap
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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--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.
Tests
I added an extensive test suite
cli_regression, that checks the script output of the new CLI against the old one i.e. it installs a secondary bender binary from themasterbranch and diffs the two outputs.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?)cli_regressiontest suitelower_casei.e.vendorhad some.