Skip to content

fix(cli): complete --indent with numbers, positional args with files - #66

Merged
reteps merged 1 commit into
mainfrom
fix/indent-completion
Nov 2, 2026
Merged

reteps merged 1 commit into
mainfrom
fix/indent-completion

Conversation

@reteps

@reteps reteps commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #64.

  • dockerfmt -i <TAB> / --indent <TAB> now suggests 2, 4, 8 with ShellCompDirectiveNoFileComp, instead of falling back to filename completion.
  • Related bug found while reproducing: dockerfmt <TAB> returned NoFileComp (cobra does this for a root command with subcommands), so Dockerfile paths never completed. A ValidArgsFunction now re-enables file completion for positional args. Subcommand names are still offered.

Test plan

  • New cmd/root_test.go drives cobra's __complete protocol (what the zsh/bash/fish scripts call). It fails on main and passes with this change.
  • go test ./...

🤖 Generated with Claude Code

In zsh, `dockerfmt -i <TAB>` offered filenames because --indent had no
completion function, so cobra fell back to file completion. Suggest common
indent widths instead.

Positional arguments (Dockerfiles) had the opposite problem: because the
root command has subcommands, cobra returned NoFileComp, so file paths
never completed. Add a ValidArgsFunction that re-enables file completion.

Fixes #64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@reteps
reteps merged commit a5868c2 into main Nov 2, 2026
3 checks passed
@reteps
reteps deleted the fix/indent-completion branch November 14, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zsh completion malfunction

1 participant