summaryrefslogtreecommitdiffstats
path: root/doc/development
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2014-09-16 15:50:04 -0700
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2014-10-22 13:11:55 -0500
commit5c0b8c2b0229992671e076e74c1256a880381d62 (patch)
treed112dd9129e8e44fd17633fe13d2a359bdbeebbc /doc/development
parent56d2b72b6f8b2e1a27a16dbfdab10f0b83816ceb (diff)
downloadbcfg2-5c0b8c2b0229992671e076e74c1256a880381d62.tar.gz
bcfg2-5c0b8c2b0229992671e076e74c1256a880381d62.tar.bz2
bcfg2-5c0b8c2b0229992671e076e74c1256a880381d62.zip
testsuite: Added unit tests for new option parsing
Diffstat (limited to 'doc/development')
-rw-r--r--doc/development/option_parsing.txt15
1 files changed, 9 insertions, 6 deletions
diff --git a/doc/development/option_parsing.txt b/doc/development/option_parsing.txt
index 091f43cdd..642b9a36c 100644
--- a/doc/development/option_parsing.txt
+++ b/doc/development/option_parsing.txt
@@ -174,28 +174,31 @@ The normal implementation pattern is this:
#. Define all of your subcommands as children of
:class:`Bcfg2.Options.Subcommand`.
-#. Define a :class:`Bcfg2.Options.CommandRegistry` object that will be
+#. Create a :class:`Bcfg2.Options.CommandRegistry` object that will be
used to register all of the commands. Registering a command
collect its options and adds it as a
:class:`Bcfg2.Options.Subparser` option group to the main option
parser.
#. Register your commands with
- :func:`Bcfg2.Options.register_commands`, parse options, and run.
+ :func:`Bcfg2.Options.register_commands`.
+#. Add options from the
+ :attr:`Bcfg2.Options.CommandRegistry.command_options`
+ attribute to the option parser.
+#. Parse options, and run.
:mod:`Bcfg2.Server.Admin` provides a fairly simple implementation,
-where the CLI class is itself the command registry:
+where the CLI class subclasses the command registry:
.. code-block:: python
class CLI(Bcfg2.Options.CommandRegistry):
def __init__(self):
Bcfg2.Options.CommandRegistry.__init__(self)
- Bcfg2.Options.register_commands(self.__class__,
- globals().values(),
- parent=AdminCmd)
+ self.register_commands(globals().values(), parent=AdminCmd)
parser = Bcfg2.Options.get_parser(
description="Manage a running Bcfg2 server",
components=[self])
+ parser.add_options(self.subcommand_options)
parser.parse()
In this case, commands are collected from amongst all global variables