-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
AutoCLI improve default value handling #14719
Comments
It seems like the solution is to mark the flags as required. However, we need a way to know which flag is required for a specific query. Is this something we want to add in the protos @aaronc (this does not look supported by our tooling however)? Something naive like this unfortunately will lead having too many flags required. Especially that it can differ per chain. binder, err := b.AddMessageFlags(cmd.Context(), cmd.Flags(), inputType, options)
if err != nil {
return nil, err
}
// mark all flags as required except optional
cmd.Flags().VisitAll(func(f *pflag.Flag) {
if f.Name == "pagination" || strings.HasPrefix(f.Name, "page-") {
return
}
cmd.MarkFlagRequired(f.Name)
}) |
We could look into Maybe we create a simple |
SGTM. If the field is nil, we can assume it was unset, right? |
If a scalar field is marked as |
For fields in Msg's (as opposed to queries), it seems like maybe the default assumption should probably be that all fields are required and thus positional parameters. Generally for autocli, it feels like it would be cleanest to assume things are required and thus positional unless explicitly marked as What if we added an autocli module option like |
I agree with this personally I also feel that better to be explicit with optional rather than with mandatory. I vote for this change! |
@julienrbrt is this solved? |
No, but I think to achieve a better UX you should just use positional argument instead. |
Improve the handling of default values. Currently, the default value of a parameter is set to the default go.
Which is, when that default value a valid value for a query, leads to some confusing behavior:
ref: #14696 (comment)
The text was updated successfully, but these errors were encountered: