-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Enable to customize completion commands #2103
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
Conversation
This allows you to customize completion command.
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.
@suzuki-shunsuke we have the docs to show how to invoke this https://cli.urfave.org/v3/examples/completions/shell-completions/
We generally want to keep the cli binary to a minimum so we avoid unnecessary descriptions/etc. I am not against adding the command description as part of the command but I would like others to chime in here
I'm aware of the document. I set the default usage and description to make it user friendly, but if you are against, it's okay to remove them. |
```sh make generate ```
```sh make v3approve ```
@suzuki-shunsuke do you want to update the docs under docs/v3/completions to include this as well ? That way I can push docs out to server once we merge this in |
Sure. Updated. 23f8f56 |
@suzuki-shunsuke urfave/cli is declarative in nature. So instead of exporting the completion command we should add a flag saying whether the completion command should be hidden or not. So usage would be
Advantage of this method is that we dont need to export the completion command. Disadvantage is that we can change only the hidden value for command but not usage or description. |
Hmm. If the completion command is shown, its usage and description should be configurable. How about adding a method to configure the completion command? e.g. cmd := &cli.Command{
SetCompletionCommand: func(cmd *cli.Command) error { // cmd is a completion command
cmd.Hidden = false
cmd.Usage = "..."
cmd.Description = "..."
return nil
},
} Or is |
How about this? |
buildCompletionCommand
and set default usage and description
@suzuki-shunsuke You have to run "make v3approve" since the public API has changed |
I updated this pull request and added a field // ConfigureShellCompletionCommand is a function to configure a shell completion command
type ConfigureShellCompletionCommand func(*Command)
Done. d82d555 |
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
To customize completion command's fields such as
Hidden
,Usage
, andDescription
.Which issue(s) this PR fixes:
(REQUIRED)
Special notes for your reviewer:
(fill-in or delete this section)
Testing
(fill-in or delete this section)
Release Notes
(REQUIRED)