Our great sponsors
-
complgen
Generate bash/fish/zsh completions from a single declarative grammar familiar from man pages
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
The advantage complgen has over clap_complete (currently) is that it can generate completions based on an external command output. For example for cargo, you can have this (incomplete yet) grammar that not only completes +toolchains in cargo but also suggest test names in cargo test .
See here for an example.
Interesting - I started working on something very similar a few months back: https://github.com/dob9601/intellicomp/tree/master
As for the implementation differences, complgen uses a trivial DSL that’s everybody is already familiar with more or less because it’s a slightly more rigorous version of what tools usually spit out when you do command --help (projects like docopt even use that for command line arguments parsing). Those happen to be regular languages and therefore can be represented as a Deterministic Finite Automata. complgen compiles the grammars to DFAs, minimizes the DFA and spits out shell-specific shell completions scripts that simply walk the DFA to match and complete the current input.