This module can be used to build a CLI tool with minimal custom code.
The predicate cli_main/4 takes:
- the name of the tool,
- usage specifications (positional arguments),
- flag specifications (flag arguments), and
- the tool's main goal.
It takes care of the common flags -h
/`--help and
-v/
--version`.
The following three types of command-line argument can be
distinguised:
- Runtime arguments
Should be handled by the Prolog runtime, and are therefore not
handled by this module. Runtime arguments must appear before
other arguments, and not be separated from other arguments by
--
.
- Flag arguments
Key-value pairs (with a boolean value possibly implicit) intended
to control your program in one way or another.
- Positional arguments
What remains after all runtime arguments and options have been
removed (with implicit arguments â true/false for booleans â
filled in).
- cli_main(+Name:atom, +Usages:list(list(atom)), :Goal_2) is det
- cli_main(+Name:atom, +Usages:list(list(atom)), +Specs:list(dict), :Goal_2) is det