Command Line Argument Parsing

If you are developing a command-line utility around Austin and you would like to use argparse to parse the command-line arguments, you can customise the austin.cli.AustinArgumentParser class to easily parse and validate arguments that need to be passed to the Austin binary. You can remove the Austin arguments that you don’t need by setting the corresponding argument of the constructor to False. Similarly, if you need to add extra arguments or options, you can use the add_argument method of the base argparse.ArgumentParser class.

The austin.cli.AustinArgumentParser class

class austin.cli.AustinArgumentParser(name='austin', alt_format=True, children=True, exclude_empty=True, exposure=True, full=True, interval=True, memory=True, pid=True, sleepless=True, timeout=True, command=True, **kwargs)

Bases: argparse.ArgumentParser

Austin Command Line parser.

This command line parser is based on argparse.ArgumentParser and provides a minimal implementation for parsing the standard Austin command line. The bool arguments of the constructor are used to specify whether the corresponding Austin option should be parsed or not. For example, if your application doesn’t need the possiblity of switching to the alternative format, you can exclude this option with alt_format=False.

Note that al least one between pid and command is required, but they cannot be used together when invoking Austin.

exit(status=0, message=None)

Raise exception on error.

Return type

NoReturn

parse_args(args=None, namespace=None)

Parse the list of arguments.

Return a argparse.Namespace with the parsed result. If no PID nor a command are passed, an instance of the AustinCommandLineError exception is thrown.

Return type

Namespace

static to_list(args)

Convert a argparse.Namespace to a list of arguments.

This is the opposite of the parsing of the command line. This static method is intended to filter and reconstruct the command line arguments that need to be passed to lower level APIs to start the actual Austin process.

Return type

List[str]