Skip to content

Add shell completion generation (--completions) #175

@vmvarela

Description

@vmvarela

Description

Add a --completions <shell> flag that generates shell completion scripts for bash, zsh, and fish.

# Generate bash completions
sql-pipe --completions bash > /usr/share/bash-completion/completions/sql-pipe

# Generate zsh completions
sql-pipe --completions zsh > ~/.zsh/completions/_sql-pipe

# Generate fish completions
sql-pipe --completions fish > ~/.config/fish/completions/sql-pipe.fish

Motivation

The project already has extensive packaging infrastructure (Homebrew, APT, RPM, APK, AUR, Nix, Chocolatey, Winget, Scoop). Shell completions are expected in modern CLI tools and significantly improve UX for discoverability and speed. The argument parser in args.zig (644 lines) already has an exhaustive flag list with descriptions — this metadata can be reused.

Acceptance Criteria

  • --completions <shell> flag accepts: bash, zsh, fish
  • Generated scripts include all flags with descriptions
  • Generated scripts include output format values for -O (table, json, csv, tsv, vertical, markdown, html, sql)
  • Generated scripts include input format values for -I (csv, tsv, json, ndjson, xml, yaml)
  • Scripts are self-contained (no external dependencies)
  • Integration tests verify script generation (syntax check)
  • Help text updated

Implementation Notes

  • The --help output (args.zig line 184-260) already has well-formatted descriptions
  • Iterate over the flag list and emit the right format for each shell
  • Start with bash (most requested), then zsh and fish
  • About 100-150 lines total for all three shells

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumShould be done soonsize:mMedium — 4 to 8 hoursstatus:readyRefined and ready for sprint selectiontype:featureNew functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions