Extending qiBuild actions

Writing a new qibuild action is quite simple.

When you type:

            qibuild spam


the qibuild script will look for a module named spam in the qibuild.actions package.

The only requirements for the spam module is to contain two functions:

  • configure_parser(parser)
  • do(args)

The configure_parser function takes a argparse.ArgumentParser object and modifies it.

You can modify the parser passed as argument to add specific arguments to you action.

The do function takes the result of the command line parsing. It is a argparse.Namespace object.

Quick example of a generic action::

            """Add some eggs !"""

import qisys

def configure_parser(parser):
    """Configure parser for this action """
      help="Number of eggs to add",

def do(args):
  """Main entry point"""
  qisys.ui.info("adding %i eggs" % args.num_eggs)


The call to qisys.parsers.default_parser is mandatory: It handles the logging configuration, and all the debug options.

Quick note : often you’ll want an action with two words in it, for instance foo-bar .

Although simply writing a file called foo-bar.py would work, please create a module called foo_bar.py . Note that import foo-bar will not work, Python will read it as import foo minus bar ...

Note that the command line parsing done by qibuild will replace - by _ anyway.