Open ChrisPenner opened 3 years ago
Thanks for the tip, @ChrisPenner! And also for the switch to optparse applicative.
I don't know much about Homebrew, but I set this up in the Nix derivation for ucm
and it seems to be working well. Here is the directory structure that I'm using, which I think follows the conventions for the various shells (I don't know if share
would be parent directory in homebrew though).
share
├── bash-completion
│ └── completions
│ └── ucm.bash
├── fish
│ └── vendor_completions.d
│ └── ucm.fish
└── zsh
└── site-functions
└── _ucm
I just realized that we can also auto-generate a not-completely-terrible man page for ucm
thanks to optparse-applicative generating a useful --help
:
help2man --no-info -v version ucm | nroff -man
Built January 1, 1980?
Built January 1, 1980?
Haha. My guess would be that this has to do with git or Nix normalizing a date for reproducibility/consistent hashing. But I have no idea why it would differ from what's at the top of the page. 🤷
I found an example of a project that installs shell completion as part of its homebrew formula.
I don't know homebrew or Ruby well enough to understand whether the homebrew formula could call into ucm to generate these files as part of the installation. Or would they need to be bundled into the tar file?
Does anyone who uses homebrew want to give this a try? This is the Homebrew formula that you'd need to change.
In https://github.com/unisonweb/unison/pull/2280, I swapped ucm to use optparse applicative, which means we can now get Bash, Zsh, or Fish tab-completion on arguments and commands for free! This also allows configuring custom completion types within the CLI code, and if you use the appropriate parser type for arguments it can infer that a given argument must be a file or directory, etc.
You can read about it here, but I believe all that we need to do is:
ucm
executable with the following commands as part of the release process:ucm --zsh-completion-script $(which ucm) > zsh_completion.sh
ucm --bash-completion-script $(which ucm) > bash_completion.sh