def init_argparser_advanced_options(self, argparser): """ Advanced calmjs webpack specific options. """ advanced_options = argparser.add_argument_group( 'advanced optional arguments') advanced_options.add_argument( '--disable-calmjs-compat', action='store_false', dest=CALMJS_COMPAT, default=True, help="disable calmjs compatibility; i.e. don't include the " "surrogate import loader module; disables support for " "dynamic imports", ) advanced_options.add_argument( '--webpack-entry-point', action='store', dest=WEBPACK_ENTRY_POINT, default=DEFAULT_BOOTSTRAP_EXPORT, metavar=metavar('module_alias'), help="explicitly specify the webpack entry point; only has effect " "if --disable-calmjs-compat was specified and the provided " "value must be aliased and available in the resulting " "artifact; defaults to the calmjs generated module that " "contains all discovered JavaScript modules", )
def init_argparser_working_dir( self, argparser, explanation='', help_template=('the working directory; %(explanation)s' 'default is current working directory (%(cwd)s)'), ): """ Subclass could an extra expanation on how this is used. Arguments explanation Explanation text for the default help template help_template A standard help message for this option. """ cwd = self.toolchain.join_cwd() argparser.add_argument( '--working-dir', dest=WORKING_DIR, metavar=metavar(WORKING_DIR), default=cwd, help=help_template % { 'explanation': explanation, 'cwd': cwd }, )
def init_argparser_working_dir( self, argparser, explanation='', help_template=( 'the working directory; %(explanation)s' 'default is current working directory (%(cwd)s)'), ): """ Subclass could an extra expanation on how this is used. Arguments explanation Explanation text for the default help template help_template A standard help message for this option. """ cwd = self.toolchain.join_cwd() argparser.add_argument( '--working-dir', dest=WORKING_DIR, metavar=metavar(WORKING_DIR), default=cwd, help=help_template % {'explanation': explanation, 'cwd': cwd}, )
def init_argparser_package_names( self, argparser, help='names of the python packages to use'): """ Set up option for package names """ argparser.add_argument( SOURCE_PACKAGE_NAMES, help=help, metavar=metavar('package'), nargs='+', )
def init_argparser(self, argparser): """ Other runtimes (or users of ArgumentParser) can pass their subparser into here to collect the arguments here for a subcommand. """ super(PackageManagerRuntime, self).init_argparser(argparser) # Ideally, we could use more subparsers for each action (i.e. # init and install). However, this is complicated by the fact # that setuptools has its own calling conventions through the # setup.py file, and to present a consistent cli to end-users # from both calmjs entry point and setuptools using effectively # the same codebase will require a bit of creative handling. # provide this for the setuptools command class. actions = argparser.add_argument_group('action arguments') count = 0 for full, short, desc in self.pkg_manager_options: args = [ dash + key for dash, key in zip(('-', '--'), (short, full)) if key ] # default is singular, but for the argparsed version in our # runtime permits multiple packages. desc = desc.replace('Python package', 'Python package(s)') if not short: f = getattr(self.cli_driver, '%s_%s' % (self.cli_driver.binary, full), None) if callable(f): count += 1 actions.add_argument(*args, help=desc, action=PackageManagerAction, dest=self.action_key, const=(count, f)) if self.default_action is None: self.default_action = f continue # pragma: no cover argparser.add_argument(*args, help=desc, action='store_true') argparser.add_argument( 'package_names', metavar=metavar('package'), nargs='+', help="python packages to be used for the generation of '%s'" % (self.cli_driver.pkgdef_filename, ), )
def init_argparser_package_names(self, argparser, help=( 'names of the python package to generate artifacts for; ' 'note that the metadata directory for the specified ' 'packages must be writable')): """ Default helper for setting up the package_names option. This is separate so that subclasses are not assumed for the purposes of artifact creation; they should consider modifying the default help message to reflect the fact. """ argparser.add_argument( 'package_names', metavar=metavar('package'), nargs='+', help=help)
def init_argparser(self, argparser): """ Other runtimes (or users of ArgumentParser) can pass their subparser into here to collect the arguments here for a subcommand. """ super(PackageManagerRuntime, self).init_argparser(argparser) # Ideally, we could use more subparsers for each action (i.e. # init and install). However, this is complicated by the fact # that setuptools has its own calling conventions through the # setup.py file, and to present a consistent cli to end-users # from both calmjs entry point and setuptools using effectively # the same codebase will require a bit of creative handling. # provide this for the setuptools command class. actions = argparser.add_argument_group('action arguments') count = 0 for full, short, desc in self.pkg_manager_options: args = [ dash + key for dash, key in zip(('-', '--'), (short, full)) if key ] # default is singular, but for the argparsed version in our # runtime permits multiple packages. desc = desc.replace('Python package', 'Python package(s)') if not short: f = getattr(self.cli_driver, '%s_%s' % ( self.cli_driver.binary, full), None) if callable(f): count += 1 actions.add_argument( *args, help=desc, action=PackageManagerAction, dest=self.action_key, const=(count, f) ) if self.default_action is None: self.default_action = f continue # pragma: no cover argparser.add_argument(*args, help=desc, action='store_true') argparser.add_argument( 'package_names', metavar=metavar('package'), nargs='+', help="python packages to be used for the generation of '%s'" % ( self.cli_driver.pkgdef_filename, ), )
def init_argparser_export_target( self, argparser, default=None, help='the export target', ): """ Subclass could override this by providing alternative keyword arguments and call this as its super. It should not reimplement this completely. Example: def init_argparser_export_target(self, argparser): super(MyToolchainRuntime, self).init_argparser_export_target( argparser, default='my_default.js', help="the export target, default is 'my_default.js'", ) Note that the above example will prevent its subclasses from directly using the definition of that class, but they _can_ simply call the exact same super, or invoke ToolchainRuntime's init_argparser_* method directly. Arguments default The default export target. help The help text. """ argparser.add_argument( '-w', '--overwrite', dest=EXPORT_TARGET_OVERWRITE, action='store_true', help='overwrite the export target without any confirmation', ) argparser.add_argument( '--export-target', dest=EXPORT_TARGET, metavar=metavar(EXPORT_TARGET), default=default, help=help, )
def init_argparser_build_dir( self, argparser, help=( 'the build directory, where all sources will be copied to ' 'as part of the build process; if left unspecified, the ' 'default behavior is to create a new temporary directory ' 'that will be removed upon conclusion of the build; if ' 'specified, it must be an existing directory and all files ' 'for the build will be copied there instead, overwriting any ' 'existing file, with no cleanup done after.' )): """ For setting up build directory """ argparser.add_argument( '--build-dir', default=None, dest=BUILD_DIR, metavar=metavar(BUILD_DIR), help=help, )
def init_argparser_loaderplugin_registry( self, argparser, default=None, help=( 'the name of the registry to use for the handling of loader ' 'plugins that may be loaded from the given Python packages' )): """ Default helper for setting up the loaderplugin registries flags. Note that this is NOT part of the init_argparser due to implementation specific requirements. Subclasses should consider modifying the default value help message to cater to the toolchain it encapsulates. """ argparser.add_argument( '--loaderplugin-registry', default=default, dest=CALMJS_LOADERPLUGIN_REGISTRY_NAME, action='store', metavar=metavar('registry'), help=help, )