Command line interface¶
The rzb
command¶
Razorback provides some command line tools under the rzb
command.
Typing the command shows the help message with the list of available commands :
$ rzb
Usage: rzb [OPTIONS] COMMAND [ARGS]...
The razorback command line interface.
Options:
-h, --help Show this message and exit.
Commands:
path Manipulate data path.
version Razorback installed version.
Getting the version number with rzb version
¶
To get the number of the installed version :
$ rzb version
razorback 0.4.0
Manipulating the data path with rzb path
¶
rzb path
provides several subcommands for manipulating the data path.
Just typing rzb path
performs no action but shows the help and the list of available commands :
$ rzb path
Usage: rzb path [OPTIONS] COMMAND [ARGS]...
Manipulate data path.
Data path is either global or local. If the local path is not available,
the global path is used instead.
The path commands depend on the current directory where they are executed.
Options:
-c, --create Create the local path if missing.
-h, --help Show this message and exit.
Commands:
base Current base data path.
metronix Current path for Metronix calibration files.
Without options, rzb path base
and rzb path metronix
just show the path where data, like calibration files, will be searched. This path depends on the working directory.
The option --create
will create the corresponding local path.
Extending the command line interface¶
You can add commands to the rzb
command line interface by using Click and setuptools entry points.
Let us look at an example. We have a simple Click program in our package:
# mypkg/rzb_cli.py
import click
@click.command('say-hello')
def cli():
click.echo('Hello world !')
We also have a setup.py for installing our package.
To extend the rzb
command, we need to informs the setup() function in the following way:
# setup.py
setup(
# ...
entry_points={
'rzb.commands': [
'say-hello=mypkg.rzb_cli:cli',
]
},
)
Once mypkg is installed (python setup.py install
or pip install .
), the rzb
command can now expose our new subcommand:
$ rzb say-hello
Hello world !