-
Notifications
You must be signed in to change notification settings - Fork 177
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
CLI: Put some common params in a central place #1484
Conversation
Arg::new("server") | ||
.long("server") | ||
.short('s') | ||
.help("The nickname, host name or URL of the server") |
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.
if you do .help
multiple times, does that latter one take precedence? For example, below you're doing something like server().help("custom help section for this command")
. Does this work?
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'm testing this rn
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.
confirmed this works as desired (see Testing
section)
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, ideally it would just work and save us all a lot of suffering 😅
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.
Q on this, will properly review later
@@ -0,0 +1,15 @@ | |||
use clap::Arg; |
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.
nit @jdetter does this belong more in src/
or src/subcommands
?
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 fine, leave it as is 👍
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.
Works for me, thanks Zeke 👍
@@ -0,0 +1,15 @@ | |||
use clap::Arg; |
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 fine, leave it as is 👍
@@ -27,16 +28,9 @@ pub fn cli() -> clap::Command { | |||
.help("The name of the reducer to call"), | |||
) | |||
.arg(Arg::new("arguments").help("arguments formatted as JSON").num_args(1..)) | |||
.arg(common_args::server().help("The nickname, host name or URL of the server hosting the database")) |
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.
the overrides appear to be working
boppy@boppy-macbook SpacetimeDB % spacetime call --help
Invokes a reducer function in a database
Usage: spacetime call [OPTIONS] <database> <reducer_name> [arguments]...
Arguments:
<database> The database domain or address to use to invoke the call
<reducer_name> The name of the reducer to call
[arguments]... arguments formatted as JSON
Options:
-s, --server <server> The nickname, host name or URL of the server hosting the database
-i, --identity <identity> The identity to use for the call
-a, --anon-identity If this flag is present, the call will be executed with no identity provided
-h, --help Print help
Run `spacetime help call` for more detailed information.
Co-authored-by: Zeke Foppa <github.com/bfops>
Description of Changes
Created a
crates/cli/src/common_args.rs
file that currently just contains the most common form of the--server
/-s
param and the--identity
/-i
param.API and ABI breaking changes
None
Expected complexity level and risk
1
Testing