The CLI generator Comonicon has been announced for a while and has been tagged 0.12.10 version recently. The interface has been stabilized for a while, thus I’m thinking to release its first 1.0 version. I’d like to see if there is any more feedback in terms of the APIs before I do so.
A brief review of what’s changed since the last post
More shell autocompletion support
Bash auto-completion has been added recently.
now supports autocompeting types, such as Path
, DirName
, FileName
etc. or customize the autocomplete codegen by overloading the corresponding API for your own type, e.g Base.tryparse
,
BashCompletions.emit_compgen
, ZSHCompletions.emit_action
Dash separator support
--
can be used to separate the arguments if it’s turned on.
Script compile cache is removed
The old Comonicon version uses a cache file to store the CLI compile results
to accelerate the startup time. We removed this feature/workaround in later versions
because this is more a Julia compiler issue and it only works when the application
is mainly CLI code, so there is no apparent speedup for practical cases. One should
always consider using a proper project module to let Julia compiler itself cache the result.
Better Error Handling
now Comonicon support custom CLI error exception handling, via CommandException
, CommandExit
, CommandError
exception types, and shorthand function cmd_error
, cmd_exit
to help users hide Julia stacktrace and print out help info when error. Or handling exit and exit code
without actually exit the entire process. This makes it possible to reuse the CLI code directly in other packages without worrying about unexpected exit
in the CLI.
More explicit docstring format
Previously we treat the first sentence of the markdown paragraph as the brief description,
we now making this more explicit by requiring one to use an Intro
/Introduction
section to
explicitly describe the long description, e.g
"""
command <args>
description of the command.
# Intro
asdmwds dasklsam xasdklqm dasdm, qwdjiolkasjdsa
dasklmdas weqwlkjmdas kljnsadlksad qwlkdnasd
dasklmdlqwoi, dasdasklmd qw,asd. dasdjklnmldqw.
# Args
- `arg1`: argument 1.
- `arg2`: argument 2.
- `arg3`: argument 3.
- `arg4`: argument 4.
"""
PackageCompiler 2.0
Comonicon has reworked it is built on top of the PackageCompiler 2.0 now, and will use Scratch space to manage each CLI’s environment TOML file and their system images. This will help the installed CLI get managed and correctly garbage collected by Julia’s Pkg
manager.
CLI plugins
except forwarding CASTED_COMMANDS
constant to create plugin package of a CLI application. We now support the dash convention of plugins, e.g git-remote
will be the plugin of git
, this can be turned on via
[command]
plugin=true