diff options
Diffstat (limited to 'gr-utils/python/modtool/modtool_newmod.py')
-rw-r--r-- | gr-utils/python/modtool/modtool_newmod.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/gr-utils/python/modtool/modtool_newmod.py b/gr-utils/python/modtool/modtool_newmod.py index 3e05ecbf48..4382d9be7d 100644 --- a/gr-utils/python/modtool/modtool_newmod.py +++ b/gr-utils/python/modtool/modtool_newmod.py @@ -23,7 +23,6 @@ import shutil import os import re -from optparse import OptionGroup from gnuradio import gr from modtool_base import ModTool, ModToolException from scm import SCMRepoFactory @@ -31,26 +30,24 @@ from scm import SCMRepoFactory class ModToolNewModule(ModTool): """ Create a new out-of-tree module """ name = 'newmod' - aliases = ('nm', 'create') + description = 'Create new empty module, use add to add blocks.' def __init__(self): ModTool.__init__(self) - def setup_parser(self): + @staticmethod + def setup_parser(parser): " Initialise the option parser for 'gr_modtool newmod' " - parser = ModTool.setup_parser(self) - parser.usage = '%prog nm [options]. \n Call %prog without any options to run it interactively.' - ogroup = OptionGroup(parser, "New out-of-tree module options") - ogroup.add_option("--srcdir", type="string", + parser.add_argument("--srcdir", help="Source directory for the module template.") - parser.add_option_group(ogroup) - return parser + parser.add_argument("module_name", metavar='MODULE-NAME', nargs='?', + help="Override the current module's name (normally is autodetected).") - def setup(self, options, args): + def setup(self, options): # Don't call ModTool.setup(), that assumes an existing module. self._info['modname'] = options.module_name if self._info['modname'] is None: - if len(args) >= 2: - self._info['modname'] = args[1] + if options.module_name: + self._info['modname'] = options.module_name else: self._info['modname'] = raw_input('Name of the new module: ') if not re.match('[a-zA-Z0-9_]+$', self._info['modname']): @@ -72,12 +69,13 @@ class ModToolNewModule(ModTool): self.options = options self._setup_scm(mode='new') - def run(self): + def run(self, options): """ * Copy the example dir recursively * Open all files, rename howto and HOWTO to the module name * Rename files and directories that contain the word howto """ + self.setup(options) print "Creating out-of-tree module in %s..." % self._dir, try: shutil.copytree(self._srcdir, self._dir) |