# 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::



import qisys

def configure_parser(parser):
"""Configure parser for this action """
qisys.parsers.default_parser(parser)
type=int)
parser.set_defaults(
num_eggs=3)

def do(args):
"""Main entry point"""

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.