Enable to customize completion commands#2103
Conversation
This allows you to customize completion command.
dearchap
left a comment
There was a problem hiding this comment.
@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)