-
Notifications
You must be signed in to change notification settings - Fork 97
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
cmd: improve user interface for help message by add default text #456
Conversation
7216120
to
4521807
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #456 +/- ##
==========================================
+ Coverage 37.01% 37.07% +0.05%
==========================================
Files 60 60
Lines 6886 6892 +6
==========================================
+ Hits 2549 2555 +6
Misses 4042 4042
Partials 295 295
|
72a19f5
to
b0bfbf2
Compare
internal/flags/flags.go
Outdated
Destination: &args.SnapshotterConfigPath, | ||
}, | ||
&cli.StringFlag{ | ||
Name: "nydusd-config", | ||
Aliases: []string{"config-path"}, | ||
Usage: "path to the nydusd configuration", | ||
Usage: "path to nydusd configuration (such as: nydusd-config.json or configuration_v2.toml)", |
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.
nydusd-config.json or nydusd-config-v2.toml
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.
Fixed.
b0bfbf2
to
9c479a3
Compare
cmd/containerd-nydus-grpc/main.go
Outdated
@@ -94,7 +94,7 @@ func main() { | |||
return errors.Wrap(err, "set up logger") | |||
} | |||
|
|||
log.L.Infof("Start nydus-snapshotter. PID %d Version %s FsDriver %s DaemonMode %s", | |||
log.L.Infof("Start nydus-snapshotter. PID: %d Version :%s FsDriver: %s DaemonMode: %s", |
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.
Should we make the colon very close to "Version" like Version:
PID:
?
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.
OK, I will fix it.
internal/flags/flags.go
Outdated
Destination: &args.RootDir, | ||
DefaultText: "/var/lib/containerd-nydus", |
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 can't work and may violate the current theory of how nydus-snapshotter merges configurations from 1. default values, 2. TOML configuration file 3. CLI parameters. The way assigning a default value to CLI parameters will always override values from TOML configuration file
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.
@changweige "DefaultText" will not affect the parsing of parameters, it is just a prompt message to let users know the value when no CLI parameters and configuration files are specified. The "Value" field is the real default value of the CLI.
Please refer to: https://cli.urfave.org/v2/examples/flags/#default-values-for-help-output
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 see. Thanks for your elaboration. Can we use the default values defined in config/default.go
as the DefaultText
value? In order to avoid cyclic dependency, we can move function ParseParameters
to flags package?
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 see. Thanks for your elaboration. Can we use the default values defined in
config/default.go
as theDefaultText
value? In order to avoid cyclic dependency, we can move functionParseParameters
to flags package?
Good idea, I will try to do it.
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.
In summary, we can't give a default value for CLI parameters unless we can judge if it is ever specified by users in ParseParameters()
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.
Need rebase 🥹
9c479a3
to
b731369
Compare
internal/constant/cmd.go
Outdated
|
||
package constant | ||
|
||
const ( |
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.
Why the source file is named as cmd.go ?
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 think the constants in this file are prepared for the cmd and config package, what name do you think is better?
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 about values.go or constants.go?
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.
values.go looks good.
Move some string constants in CLI config to a new package for easier future refactoring. Signed-off-by: Qinqi Qu <quqinqi@linux.alibaba.com>
1. Fix missing default values in the --help after v0.6.1. 2. Sort out some usage information. Signed-off-by: Qinqi Qu <quqinqi@linux.alibaba.com>
b731369
to
e835623
Compare
@sctb512 Please check the optimizer E2E test. It randomly fails, which is somewhat upset. |
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
Current help message: