sireum / kekinian

Sireum: A High Assurance System Engineering Platform
http://sireum.org
BSD 2-Clause "Simplified" License
9 stars 2 forks source link

Add compgen.sc (cli completion generator) #2

Closed matthewweis closed 1 year ago

matthewweis commented 1 year ago

Adds a standalone Slang script that can generate cli completions for the sireum command. It is completely optional, and works similar to cli.sc (except it outputs completions instead of CliOpts as JSON). The script will work for any valid cli.sc and has been placed next to the top-level cli.sc in order to generate completions for all tools when ran. It recognizes a number of special cases, such as enums and flags expecting files. Here is a demo gif.

I am happy to make any changes to the code as needed.

Example Usage:

robby-phd commented 1 year ago

It seems that it would be better to make the script as a Slash script and make the cli.sc as the script argument, then put it in the /bin directory. What do you think?

matthewweis commented 1 year ago

Good idea, the /bin directory does seem more appropriate. I have updated the PR accordingly and am open to any feedback. I can also make the script accept the CliOpt JSON directly (instead of invoking cli.sc from within the script) if preferable.