grokkit/cmd/completion.go
Greg Gauthier e355142c05 feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00

68 lines
1.8 KiB
Go

package cmd
import (
"os"
"github.com/spf13/cobra"
)
var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate shell completion script",
Long: `Generate shell completion script for grokkit.
To load completions:
Bash:
$ source <(grokkit completion bash)
# To load completions for each session, execute once:
# Linux:
$ grokkit completion bash > /etc/bash_completion.d/grokkit
# macOS:
$ grokkit completion bash > $(brew --prefix)/etc/bash_completion.d/grokkit
Zsh:
# If shell completion is not already enabled in your environment,
# you will need to enable it. You can execute the following once:
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
# To load completions for each session, execute once:
$ grokkit completion zsh > "${fpath[1]}/_grokkit"
# You will need to start a new shell for this setup to take effect.
Fish:
$ grokkit completion fish | source
# To load completions for each session, execute once:
$ grokkit completion fish > ~/.config/fish/completions/grokkit.fish
PowerShell:
PS> grokkit completion powershell | Out-String | Invoke-Expression
# To load completions for every new session, run:
PS> grokkit completion powershell > grokkit.ps1
# and source this file from your PowerShell profile.
`,
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
cmd.Root().GenBashCompletion(os.Stdout)
case "zsh":
cmd.Root().GenZshCompletion(os.Stdout)
case "fish":
cmd.Root().GenFishCompletion(os.Stdout, true)
case "powershell":
cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
}
},
}
func init() {
rootCmd.AddCommand(completionCmd)
}