-
Notifications
You must be signed in to change notification settings - Fork 0
feat: CLI UX improvements — completion, colored output, progress bar #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
69f8399
build: add fatih/color and schollz/progressbar dependencies for CLI UX
spencercjh 7c00ee7
feat(cli): add colored output package with success/error/hint helpers
spencercjh b555236
feat(cli): add shell completion subcommand (bash/zsh/fish/powershell)
spencercjh af5b506
feat(enricher): add progress bar to batch processing
spencercjh 04912b4
feat(cli): add shell completion for enum flags (provider, language, f…
spencercjh a22f6e0
feat(cli): apply colored output to root and spring commands
spencercjh 16d04d0
style: add nolint comments for errcheck on completion registration an…
spencercjh ba4d50f
refactor: replace nolint errcheck with proper error handling
spencercjh 3efe8f9
build: promote progressbar to direct dependency in go.mod
spencercjh 1e0471a
docs: add CLI UX improvements design spec and implementation plan
spencercjh 071fd4c
chore: remove CLI UX design spec and plan docs after implementation
spencercjh 13dec60
refactor(cli): clean up output package per code review
spencercjh 01839b3
fix(cli): use os.LookupEnv for NO_COLOR and preserve fatih/color TTY …
spencercjh eb6679b
fix(enricher): move progress bar Add inside mutex for atomic updates
spencercjh dbf950e
docs: align design doc with actual implementation
spencercjh 4bc8d5a
fix(cli): remove invalid yaml/json completion for enrich --output flag
spencercjh e7844a3
test(cli): rewrite ColorEnabled tests to verify invariants
spencercjh cf4cd62
fix(cli): remove duplicate error output from Execute()
spencercjh 68eaf27
fix(enricher): show consistent failure count in concurrent progress bar
spencercjh c471da0
fix(test): preserve NO_COLOR presence/absence state in TestStatusFunc…
spencercjh e1a76e7
refactor(cmd): demote user-facing slog.Info to slog.Debug in generate
spencercjh df687da
fix(cli): make Hintf emit single atomic write to prevent interleaved …
spencercjh 34d0354
docs(design): align auto-detection section with actual initColorState…
spencercjh 7f64d80
fix(cmd): restore generation start status message via cli.Statusf
spencercjh 73bd593
fix(cmd): include source spec file path in publish status output
spencercjh 46547ce
fix(cmd): promote build file restore messages to user-facing cli output
spencercjh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "log/slog" | ||
| "os" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // completionCmd represents the completion command | ||
| var completionCmd = &cobra.Command{ | ||
| Use: "completion [bash|zsh|fish|powershell]", | ||
| Short: "Generate shell completion script", | ||
| Long: `Generate shell completion script for spec-forge. | ||
|
|
||
| To load completions: | ||
|
|
||
| Bash: | ||
| source <(spec-forge completion bash) | ||
|
|
||
| # To load completions for each session, execute once: | ||
| # Linux: | ||
| spec-forge completion bash > /etc/bash_completion.d/spec-forge | ||
| # macOS: | ||
| spec-forge completion bash > $(brew --prefix)/etc/bash_completion.d/spec-forge | ||
|
|
||
| Zsh: | ||
| # If shell completion is not already enabled in your environment, | ||
| # you will need to enable it. Add the following to your ~/.zshrc: | ||
| autoload -Uz compinit | ||
| compinit | ||
|
|
||
| # Then load completions: | ||
| spec-forge completion zsh > "${fpath[1]}/_spec-forge" | ||
|
|
||
| # You will need to start a new shell for this setup to take effect. | ||
|
|
||
| Fish: | ||
| spec-forge completion fish | source | ||
|
|
||
| # To load completions for each session, execute once: | ||
| spec-forge completion fish > ~/.config/fish/completions/spec-forge.fish | ||
|
|
||
| PowerShell: | ||
| spec-forge completion powershell | Out-String | Invoke-Expression | ||
|
|
||
| # To load completions for every new session, run: | ||
| spec-forge completion powershell > spec-forge.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), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| switch args[0] { | ||
| case "bash": | ||
| return cmd.Root().GenBashCompletion(os.Stdout) | ||
| case "zsh": | ||
| return cmd.Root().GenZshCompletion(os.Stdout) | ||
| case "fish": | ||
| return cmd.Root().GenFishCompletion(os.Stdout, true) | ||
| case "powershell": | ||
| return cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout) | ||
| default: | ||
| return nil | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| rootCmd.AddCommand(completionCmd) | ||
| } | ||
|
|
||
| // newCompletionCmd creates a new completion command instance for testing. | ||
| func newCompletionCmd() *cobra.Command { | ||
| return &cobra.Command{ | ||
| Use: "completion [bash|zsh|fish|powershell]", | ||
| Short: "Generate shell completion script", | ||
| Long: completionCmd.Long, | ||
| DisableFlagsInUseLine: true, | ||
| ValidArgs: []string{"bash", "zsh", "fish", "powershell"}, | ||
| Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), | ||
| RunE: completionCmd.RunE, | ||
| } | ||
| } | ||
|
|
||
| // registerCompletion registers shell completion for a flag. Errors are logged | ||
| // as warnings since completion is best-effort and should not block startup. | ||
| func registerCompletion(cmd *cobra.Command, flag string, completions []string) { | ||
| if err := cmd.RegisterFlagCompletionFunc(flag, | ||
| cobra.FixedCompletions(completions, cobra.ShellCompDirectiveNoFileComp), | ||
| ); err != nil { | ||
| slog.Warn("failed to register flag completion", "flag", flag, "error", err) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.