Skip to content

Conversation

@httpdss
Copy link
Owner

@httpdss httpdss commented Aug 15, 2025

Summary

  • Replace custom completion wiring with shtab-generated static completions.
  • Add --print-completion to emit completion scripts for bash/zsh/tcsh.
  • Add completion subcommand with install, generated by shtab.
  • Keep existing CLI flags intact; no breaking changes.

Why

  • shtab centralizes completion generation based on argparse definitions, reducing drift between help text and completions.
  • Faster iteration: changes to options/choices immediately reflect in completions after regeneration.

Key changes

  • completions: switch to shtab static completions
    • expose argparse parser for shtab
    • add --print-completion and completion install
  • generate: improve template variable parsing/merging logic

Installation and usage

  • Zsh:
    struct completion install zsh

    or:

    struct --print-completion zsh > ~/.zfunc/_struct && autoload -Uz compinit && compinit
  • Bash:
    struct completion install bash

    or:

    struct --print-completion bash | sudo tee /etc/bash_completion.d/struct >/dev/null
  • tcsh:
    struct --print-completion tcsh

Notes

  • Completions now come from shtab output; re-run the generator when CLI options change.
  • Dynamic suggestions for struct generate can be layered later if desired.

Testing

  • Verified on zsh 5.9 and bash 5.x; unit tests pass; docs updated.

Checklist

  • Feature works locally
  • Unit tests pass
  • Docs updated
  • No breaking changes

…_parser() for shtab\n- Add --print-completion via shtab when available\n- Rework Detected shell: zsh

# Install shtab (once, in your environment):
python -m pip install shtab

# Generate static zsh completion for 'struct':
mkdir -p ~/.zfunc
python -m shtab struct_module.main:get_parser -s zsh -o ~/.zfunc/_struct

# Ensure zsh loads user functions/completions (append to ~/.zshrc if needed):
echo "fpath=(~/.zfunc $fpath)" >> ~/.zshrc
echo "autoload -U compinit && compinit" >> ~/.zshrc

# Apply now (or open a new shell):
exec zsh

Tip: You can also print completion directly via: struct --print-completion <shell> to generate static files for zsh/bash/fish\n- Replace argcomplete with shtab in requirements.txt
chef-cookbook
ci-cd-pipelines
cloudformation-files
configs/codeowners
configs/devcontainer
configs/editor-config
configs/eslint
configs/jshint
configs/kubectl
configs/prettier
docker-files
documentation-template
git-hooks
github/chatmodes/plan
github/instructions/generic
github/prompts/generic
github/prompts/react-form
github/prompts/security-api
github/prompts/struct
github/templates
github/workflows/codeql
github/workflows/execute-tf-workflow
github/workflows/labeler
github/workflows/pre-commit
github/workflows/release-drafter
github/workflows/run-struct
github/workflows/stale
helm-chart
kubernetes-manifests
project/custom-structures
project/generic
project/go
project/java
project/n8n
project/nodejs
project/python
project/ruby
project/rust
prompts/run-struct-trigger
terraform/apps/aws-accounts
terraform/apps/environments
terraform/apps/generic
terraform/apps/github-organization
terraform/apps/init
terraform/modules/generic
vagrant-files and dynamic zsh completion for structure names
@httpdss httpdss changed the title Feat/shtab completions feat: switch to shtab-generated shell completions and add --print-completion Aug 16, 2025
@httpdss httpdss marked this pull request as ready for review August 16, 2025 18:53
@httpdss httpdss merged commit e3973e2 into main Aug 16, 2025
3 checks passed
@httpdss httpdss deleted the feat/shtab-completions branch August 16, 2025 18:53
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.

2 participants