| 24 | var currentShellFn = completion.CurrentShell |
| 25 | |
| 26 | func (i *integrateCmd) Command(celer *configs.Celer) *cobra.Command { |
| 27 | command := &cobra.Command{ |
| 28 | Use: "integrate", |
| 29 | Short: "Integrate shell tab completion.", |
| 30 | Long: `Integrate shell tab completion for celer commands. |
| 31 | |
| 32 | This command will install or remove shell completion scripts. |
| 33 | On Linux, celer integrates completion for your current shell (bash or zsh). |
| 34 | On Windows, celer integrates PowerShell completion. |
| 35 | |
| 36 | Examples: |
| 37 | celer integrate # Install tab completion |
| 38 | celer integrate --remove # Remove tab completion`, |
| 39 | Args: cobra.NoArgs, |
| 40 | RunE: func(cobraCmd *cobra.Command, args []string) error { |
| 41 | return i.execute() |
| 42 | }, |
| 43 | ValidArgsFunction: i.completion, |
| 44 | } |
| 45 | |
| 46 | // Register flags. |
| 47 | command.Flags().BoolVar(&i.remove, "remove", false, "remove shell tab completion") |
| 48 | |
| 49 | // Silence cobra's error and usage output to avoid duplicate messages. |
| 50 | command.SilenceErrors = true |
| 51 | command.SilenceUsage = true |
| 52 | return command |
| 53 | } |
| 54 | |
| 55 | // execute performs the main logic for integration. |
| 56 | func (i *integrateCmd) execute() error { |