@@ -43,16 +43,26 @@ func NewCompletionCommand() *cli.Command {
4343 Name : "completion" ,
4444 Usage : "Generate shell completion script" ,
4545 ArgsUsage : "<bash|zsh|fish>" ,
46- Description : "Generate a shell completion script for createos.\n \n " +
47- " Add the output to your shell profile to enable tab completion.\n \n " +
48- " Bash:\n " +
49- " source <(createos completion bash)\n \n " +
50- " Zsh:\n " +
51- " source <(createos completion zsh)\n \n " +
52- " Fish:\n " +
53- " createos completion fish | source" ,
46+ Flags : []cli.Flag {
47+ & cli.StringFlag {Name : "shell" , Usage : "Shell type: bash, zsh, or fish" },
48+ },
49+ Description : "Generate a shell completion script and load it into your shell.\n \n " +
50+ " Bash — add to ~/.bashrc:\n " +
51+ " echo 'source <(createos completion bash)' >> ~/.bashrc\n " +
52+ " source ~/.bashrc\n \n " +
53+ " Zsh — add to ~/.zshrc:\n " +
54+ " echo 'source <(createos completion zsh)' >> ~/.zshrc\n " +
55+ " source ~/.zshrc\n \n " +
56+ " Fish — add to fish config:\n " +
57+ " createos completion fish > ~/.config/fish/completions/createos.fish\n \n " +
58+ " To load once for the current session only (without persisting):\n " +
59+ " source <(createos completion bash)\n " +
60+ " source <(createos completion zsh)" ,
5461 Action : func (c * cli.Context ) error {
55- shell := c .Args ().First ()
62+ shell := c .String ("shell" )
63+ if shell == "" {
64+ shell = c .Args ().First ()
65+ }
5666 switch shell {
5767 case "bash" :
5868 fmt .Println (bashScript )
0 commit comments