cli: introduce Git-like commands
This patch makes the barectf CLI work with commands like Git:
$ barectf COMMAND COMMAND-ARGS
The goal of this change is to have the `barectf` tool perform more than
tracer generation in the future. For instance, the current
`--dump-config` option should be a dedicated command instead of being
part of the generation process.
As of this patch, the only available command is `generate` (with a `gen`
alias) which does exactly what `barectf` does without an explicit
command:
$ barectf generate config.yaml
$ barectf config.yaml
`--help` and `--version` are "general" options; you need to put them
before the command name, if any:
$ barectf --help
$ barectf --version
You can also put `--help` after the command name to get this command's
help:
$ barectf generate --help
`argpar.py` is a Python equivalent of the low-level parts of
<https://github.com/efficios/argpar> which I originally wrote for
Babeltrace 2.
While I acknowledge that it's ludicrous to write a custom argument
parser in Python considering that the standard library and PyPI packages
offer many of them, I couldn't find one which can satisfy the "default
command" use case, with this default command accepting a non-option
argument. For:
$ barectf config.yaml
all of them indicate that `config.yaml` is not a valid command name.
Of course this is because there's ambiguity when your configuration file
happens to be named `generate` in the current working directory:
$ barectf generate
This can also be the `generate` command with a missing configuration
file path. As of this patch, this is what happens: `barectf` prefers the
command name. It is such a corner case that I'm not spending ONE MINUTE
on it. That being said, there's a workaround:
$ barectf ./generate
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.023042 seconds and 4 git commands to generate.