plainbox.impl.commands – shared code for plainbox sub-commands

Warning

THIS MODULE DOES NOT HAVE STABLE PUBLIC API

class plainbox.impl.commands.PlainBoxCommand[source]

Simple interface class for plainbox commands.

Command objects like this are consumed by PlainBoxTool subclasses to implement hierarchical command system. The API supports arbitrary many sub commands in arbitrary nesting arrangement.

gettext_domain = 'plainbox'
class plainbox.impl.commands.PlainBoxToolBase[source]

Base class for implementing commands like ‘plainbox’.

The tools support a variety of sub-commands, logging and debugging support. If argcomplete module is available and used properly in the shell then advanced tab-completion is also available.

There are four methods to implement for a basic tool. Those are:

  1. get_exec_name() – to know how the command will be called
  2. get_exec_version() – to know how the version of the tool
  3. add_subcommands() – to add some actual commands to execute
  4. get_config_cls() – to know which config to use

This class has some complex control flow to support important and interesting use cases. There are some concerns to people that subclass this in order to implement their own command line tools.

The first concern is that input is parsed with two parsers, the early parser and the full parser. The early parser quickly checks for a fraction of supported arguments and uses that data to initialize environment before construction of a full parser is possible. The full parser sees the reminder of the input and does not re-parse things that where already handled.

The second concern is that this command natively supports the concept of a config object and a provider object. This may not be desired by all users but it is the current state as of this writing. This means that by the time eary init is done we have a known provider and config objects that can be used to instantiate command objects in add_subcommands(). This API might change when full multi-provider is available but details are not known yet.

add_early_parser_arguments(parser)[source]

Overridden version of add_early_parser_arguments().

This method adds the -c|–checkbox argument to the set of early parser arguments, so that it is visible in autocomplete and help.

classmethod get_config_cls()[source]

Get the Config class that is used by this implementation.

This can be overridden by subclasses to use a different config class that is suitable for the particular application.

get_provider_list(ns)[source]

Get the list of job providers.

This method looks at –providers argument to figure out which providers to expose to all of the commands.

late_init(early_ns)[source]

Overridden version of late_init().

This method loads the configuration object and the list of providers and stores them as instance attributes.

Previous topic

plainbox.impl.color – ANSI color codes

Next topic

plainbox.impl.commands.analyze – analyze sub-command

This Page