summaryrefslogtreecommitdiffstats
path: root/doc/development
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2014-11-10 19:55:53 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2014-11-10 19:55:53 +0100
commit3f32d999c6e75af57058e389a07d1ab6a62eaebb (patch)
tree6055de1e6a541e2e5e4a721058f414a0e50258b6 /doc/development
parentda93fb540c28be3341ec0d37d1fbd90153fb750c (diff)
parent0e133c157755908d05c44c3a36b1dc0668e1d111 (diff)
downloadbcfg2-3f32d999c6e75af57058e389a07d1ab6a62eaebb.tar.gz
bcfg2-3f32d999c6e75af57058e389a07d1ab6a62eaebb.tar.bz2
bcfg2-3f32d999c6e75af57058e389a07d1ab6a62eaebb.zip
Merge branch 'options-unit-tests' of https://github.com/stpierre/bcfg2
* 'options-unit-tests' of https://github.com/stpierre/bcfg2: Options: Fixed non-path database name parsing Options: further command registry fixes Options: gather as much data from config file first Options: fix path canonicalization and file-like objects testsuite: unlink temporary files Options: ensure <repository> macros are always fixed up DBSettings: fix up <repository> in database name testsuite: better debug capturing for options tests call shutdown on subcommand registries fixed some places where plugin loading should fail silently testsuite: Added unit tests for new option parsing testsuite: capture stderr by default Test failure to parse config file when bcfg2.conf exists testsuite: skip nested exclusive option group test on py2.6 testsuite: Added unit tests for new option parsing
Diffstat (limited to 'doc/development')
-rw-r--r--doc/development/option_parsing.txt20
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/development/option_parsing.txt b/doc/development/option_parsing.txt
index 091f43cdd..e14031e1e 100644
--- a/doc/development/option_parsing.txt
+++ b/doc/development/option_parsing.txt
@@ -174,28 +174,32 @@ 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.
+#. Register your commands with the
+ :func:`Bcfg2.Options.CommandRegistry.register_commands` method of
+ your ``CommandRegistry`` object.
+#. 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
@@ -208,9 +212,7 @@ At a minimum, the :func:`Bcfg2.Options.Subcommand.run` method must be
overridden, and a docstring written.
.. autoclass:: Subcommand
-.. autoclass:: HelpCommand
.. autoclass:: CommandRegistry
-.. autofunction:: register_commands
Actions
-------