Skip to content

Commit c7dbe0e

Browse files
chore: updated completion
1 parent ddf91fc commit c7dbe0e

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ createos --help
200200
| Command | Description |
201201
| --------------------- | ------------------------------------------------------- |
202202
| `createos ask` | Ask the AI assistant to help manage your infrastructure |
203-
| `createos completion` | Generate shell completion script (bash/zsh/fish/powershell) |
203+
| `createos completion` | Generate shell completion script (bash/zsh/fish) |
204204
| `createos version` | Print the current version |
205205

206206
## Non-interactive / CI usage

cmd/completion/completion.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)