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: de-clutter CLI #7107
cli: de-clutter CLI #7107
Conversation
As recommended by Helder, visually break sections using bold uppercase for titles. I also removed the special template for the query subcommand: it was used to put the example after the flags. However, this created a special UX just for this sub-command. We should better have a consistent positioning of examples prior args or after on all subcommands, so on the main template Signed-off-by: grouville <guillaume@dagger.io>
When querying `dagger call --help` and `dagger functions --help` without being in a module, an error is being raised. This commit adds a newline between the two, as it was hard to distinct between them Signed-off-by: grouville <guillaume@dagger.io>
Remove colon from usage, as it is now bold and is redundent Signed-off-by: grouville <guillaume@dagger.io>
…mands" and "flags" 1. Conventionalize on either <command> or COMMAND syntax in cmd.Use 2. Talk about "functions" and "arguments", rather than "function commands" and "flags" 3. "Options" instead of "Flags"? Solomon prefers arguments Signed-off-by: grouville <guillaume@dagger.io>
Instead of Flags, rely on the option terminology. To comply with Solomon's request of arguments and functions, in the context of functions I kept Solomon's terminology: arguments, and for the rest it is options Signed-off-by: grouville <guillaume@dagger.io>
1. Use OPTIONS everywhere instead of FLAGS 2. Overrides Cobra's default [flags] printing 3. Finish standardizing all options as uppercase Signed-off-by: grouville <guillaume@dagger.io>
A separate PR for each item would actually be preferred, especially if it can stand on its own or it may warrant some discussion or design decision. In that case, don't forget to remove the "Fixes" here, so this doesn't close the issue until all PRs are marged.
👍
Yes, it's applied everywhere. The idea is to choose a syntax for representing usage and stick to it. Last time I changed to The
Cobra’s default is to put flags after subcommands. In some cases it seemed like I was looking for the flags next to the usage line, so I experimented with moving them there. That’s that However, when you have a lot of sub-commands, as when you do Note that with
I wouldn’t put an It’s what Typer does, for example:
The idea of a “required option” can be strange though, but at least right now that only happens in
Also, remember that If it was just the latter, it would be simply a matter of customizing the name of the section via an annotation, for example. But I think there’s a value in separating the flags in How to do that? If you see how marking a flag as required works, Cobra is adding an annotation through the flagset. So you can just create an annotation for marking a flag as a “function argument”, and in the template, similarly to how you handle required flags, you split argument flags, and if there’s any, show a section below “Options” for “Arguments”. Both sections will only show at the same time in the top-level I suggest three separate PRs then:
Not a priority, better create a separate issue for this. The intent is to provide more information to the user in the CLI (i.e., without requiring a visit to the docs), while reducing the clutter in normal
Since Dagger has its nuances, I’ve been wondering which approach is better here. We could just “link” to the web for more information. \cc @vikram-dagger
The way I’ve envisioned this is through I think some of those can be useful at “top level” though (direct child of root), especially So I’d just not add these flagsets to “function” sub-commands in
Already talked about this in a previous point. To reiterate, "Options" is also closer to function arguments than “Flags”, but it’s better to have constructor arguments in None of this applies to |
@grouville, with "Figure out if arguments are better above or below functions/commands", I realize I wasn't clear in addressing your question. The answer to doing it only for Note that only |
1. Rename all the flag mentions to "options", as proposed by Helder in dagger#7107 (comment) 2. Remove the automatic [flags] append on all commands: dagger#7107 (comment) Signed-off-by: grouville <guillaume@dagger.io>
1. Rename all the flag mentions to "options", as proposed by Helder in dagger#7107 (comment) 2. Remove the automatic [flags] append on all commands: dagger#7107 (comment) Signed-off-by: grouville <guillaume@dagger.io>
1. Rename all the flag mentions to "options", as proposed by Helder in dagger#7107 (comment) 2. Remove the automatic [flags] append on all commands: dagger#7107 (comment) 3. Set DisableFlagsInUseLine to true for AppendedSubcommands in dagger call Signed-off-by: grouville <guillaume@dagger.io>
1. Rename all the flag mentions to "options", as proposed by Helder in dagger#7107 (comment) 2. Remove the automatic [flags] append on all commands: dagger#7107 (comment) 3. Set DisableFlagsInUseLine to true for AppendedSubcommands in dagger call Signed-off-by: grouville <guillaume@dagger.io>
* cli: rename flags to options 1. Rename all the flag mentions to "options", as proposed by Helder in #7107 (comment) 2. Remove the automatic [flags] append on all commands: #7107 (comment) 3. Set DisableFlagsInUseLine to true for AppendedSubcommands in dagger call Signed-off-by: grouville <guillaume@dagger.io> * cli: fix usage of watch command - Remove the COMMAND copy-paste error, where a command is not required for the watch command - Do not show the [options], as only inherited flags are shown Signed-off-by: grouville <guillaume@dagger.io> * cli: remove [options] for dagger version Do not show [options] for command with only inherited flags Signed-off-by: grouville <guillaume@dagger.io> * cli: fix and add <pattern>... to config views add / set / remove commands Applies the recommendations from Helder on those sub commands Signed-off-by: grouville <guillaume@dagger.io> --------- Signed-off-by: grouville <guillaume@dagger.io>
* cli: rename flags to options 1. Rename all the flag mentions to "options", as proposed by Helder in dagger#7107 (comment) 2. Remove the automatic [flags] append on all commands: dagger#7107 (comment) 3. Set DisableFlagsInUseLine to true for AppendedSubcommands in dagger call Signed-off-by: grouville <guillaume@dagger.io> * cli: fix usage of watch command - Remove the COMMAND copy-paste error, where a command is not required for the watch command - Do not show the [options], as only inherited flags are shown Signed-off-by: grouville <guillaume@dagger.io> * cli: remove [options] for dagger version Do not show [options] for command with only inherited flags Signed-off-by: grouville <guillaume@dagger.io> * cli: fix and add <pattern>... to config views add / set / remove commands Applies the recommendations from Helder on those sub commands Signed-off-by: grouville <guillaume@dagger.io> --------- Signed-off-by: grouville <guillaume@dagger.io>
* cli: rename flags to options 1. Rename all the flag mentions to "options", as proposed by Helder in dagger#7107 (comment) 2. Remove the automatic [flags] append on all commands: dagger#7107 (comment) 3. Set DisableFlagsInUseLine to true for AppendedSubcommands in dagger call Signed-off-by: grouville <guillaume@dagger.io> * cli: fix usage of watch command - Remove the COMMAND copy-paste error, where a command is not required for the watch command - Do not show the [options], as only inherited flags are shown Signed-off-by: grouville <guillaume@dagger.io> * cli: remove [options] for dagger version Do not show [options] for command with only inherited flags Signed-off-by: grouville <guillaume@dagger.io> * cli: fix and add <pattern>... to config views add / set / remove commands Applies the recommendations from Helder on those sub commands Signed-off-by: grouville <guillaume@dagger.io> --------- Signed-off-by: grouville <guillaume@dagger.io>
* cli: rename flags to options 1. Rename all the flag mentions to "options", as proposed by Helder in dagger#7107 (comment) 2. Remove the automatic [flags] append on all commands: dagger#7107 (comment) 3. Set DisableFlagsInUseLine to true for AppendedSubcommands in dagger call Signed-off-by: grouville <guillaume@dagger.io> * cli: fix usage of watch command - Remove the COMMAND copy-paste error, where a command is not required for the watch command - Do not show the [options], as only inherited flags are shown Signed-off-by: grouville <guillaume@dagger.io> * cli: remove [options] for dagger version Do not show [options] for command with only inherited flags Signed-off-by: grouville <guillaume@dagger.io> * cli: fix and add <pattern>... to config views add / set / remove commands Applies the recommendations from Helder on those sub commands Signed-off-by: grouville <guillaume@dagger.io> --------- Signed-off-by: grouville <guillaume@dagger.io>
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Was split in several sub-PRs, and Helder is now continuing. Can be closed, as not relevant anymore |
Details of current draft implementation
@helderco we had a sync, but I might have forgotten some parts ahah (sorry 👼). Feel free to tell if I'm completely off on some interpretation / implementation:
Add line break between error and usage
This has been added in
cmd/dagger/functions.go
Style headings in BOLD UPPERCASE to help break sections visually
A new helper function has been added and the corresponding template has been updated
Remove discrepancy between
dagger query
and the rest of the commandsThis sub-command hasn't been updated in months and having a separate template is more coordination work. It might be time to make them 1:1 ?
Conventionalize on either
<command>
orCOMMAND
syntax in cmd.UseI updated all COMMAND as uppercase. I did not remember if you were also referencing on the usage examples inside square brackets like
[arguments]
->[ARGUMENTS]
? I followed the CLI examples we discussed and some did it that way, in doubt I applied it everywhere but totally open for changeFigure out if arguments are better above or below functions/commands ??
I experimented on this one, and I haven't found an easy way: on a given function call, I do agree that having the commands at the bottom does make sense. However, changing the order on the template directly also changes the order for commands such as:
dagger --help
. What do you think is the best implementation on this one ? Shall we tweak the template to make it specific for just thedagger call
section ? I feared adding complexity to the template logicVisual cue for required flags
As you proposed last time, the idea would be to have a required flags section for the
dagger call function
subcommands only ? Will take a look tomorrow. Same fear on the added complexity on the main template, but this one seems more manageable: it is just a section wrapped in an if to show it ondagger call
subcommand context"Options" instead of "Flags"?1
This is done, with our own implementation of
useLine
to print options instead of args by default.Solomon requested
arguments
on above issue though. I followed your terminology, but shall we make a specific case for arguments indagger call
/dagger functions
scope ?Help topics for dagger call to keep --help lean while still providing more documentation
What topics do you think we should cover first ? More than the implementation, the most important might be the documentation added to those topics. Which could be the first 2 topics to create, so that i draft the implementation tomorrow ?
Global flags only on root command and top level commands
This is the one I am currently trying to implement in a clean way (using the hiding method at first), and might need some guidance again. I have been trying to extend the
callCmd
implementation by implementing a newpersistentPreRunE
:to control the behavior and potentially use the funcCommand infos or the cmd infos to mark as hidden, as you suggested, when the call command has subcommands
However, I'm still having a hard time on this part. Will keep iterating tomorrow again
This is partially done as I used your
options
terminology globally instead ofarguments
. It is true thatarguments
is pretty accurate in adagger call functions
context, but then, do we talk aboutarguments
insidedagger functions
usage examples too ?cc @helderco