def options_hook(*args, **kwargs): # This hook allows us to append options to the root namespace root_options = init_parser() root_options.add_option('--json', action='store_true', dest='enable_json', default=None, help='render output as json (Cement CLI-API)') root_options.add_option('--debug', action='store_true', dest='debug', default=None, help='toggle debug output') root_options.add_option('--quiet', action='store_true', dest='quiet', default=None, help='disable console logging') root_options.add_option('--all', action='store_true', dest='all', default=None, help='disable full output when applicable') root_options.add_option('-r', '--regex', action='store', dest='regex', default=None, help="query string [regular expression]") root_options.add_option('-q', '--query', action='store', dest='query', default=None, help="query string [plain]") root_options.add_option('--lock-file', action='store', dest='lockfile', default=None, help="lock file path", metavar="PATH") root_options.add_option('--user', action ='store', dest='user', default=None, help='RHN user name') root_options.add_option('--pass', action='store', dest='password', default=None, help='RHN user password') root_options.add_option('--server', action ='store', dest='server', default=None, help='RHN server hostname') root_options.add_option('--port', action ='store', dest='port', default=None, help='RHN server port') root_options.add_option('--force', action ='store_true', dest='force', default=None, help='force the action') return ('root', root_options)
def options_hook(*args, **kwargs): # This hook allows us to append options to the root namespace root_options = init_parser() root_options.add_option('--json', action='store_true', dest='enable_json', default=None, help='render output as json (CLI-API)') root_options.add_option('--debug', action='store_true', dest='debug', default=None, help='toggle debug output') root_options.add_option('--quiet', action='store_true', dest='quiet', default=None, help='disable console logging') root_options.add_option('-s', '--server', action='store', dest='server', help='server fqdn/ip to connect to') root_options.add_option('-p', '--port', action='store', dest='port', help='the server port to connect on') root_options.add_option('--pid-file', action='store', dest='pid_file', help='path to pid file') root_options.add_option('--run-as', action='store', dest='process_user', help='user to run as (where applicable)') root_options.add_option('--daemonize', action='store_true', dest='daemonize', default=None, help="daemonize the process") root_options.add_option('-f', '--filter', action='store', dest='filter', help='filter string', metavar='STR') root_options.add_option('--package', action='store', dest='package', help='package name', metavar='PKG') root_options.add_option('--release', action='store', dest='release', help='rhel release version', metavar='INT') return ('root', root_options) # Import all additional (non-plugin) bootstrap libraries here # # from iustools.bootstrap import example #
def options_hook(*args, **kwargs): # This hook allows us to append options to the root namespace root_options = init_parser() root_options.add_option('-R', '--root-option', action='store_true', dest='root_option', default=None, help='Example root option') root_options.add_option('--json', action='store_true', dest='enable_json', default=None, help='render output as json (CLI-API)') root_options.add_option('--debug', action='store_true', dest='debug', default=None, help='toggle debug output') root_options.add_option('--quiet', action='store_true', dest='quiet', default=None, help='disable console logging') root_options.add_option('--test-option', action='store', dest='test_option', default=None, help='test option') return ('root', root_options)
def options_hook(*args, **kwargs): # This hook allows us to append options to the root namespace root_options = init_parser() root_options.add_option('--json', action='store_true', dest='enable_json', default=None, help='render output as json (CLI-API)') root_options.add_option('--debug', action='store_true', dest='debug', default=None, help='toggle debug output') root_options.add_option('--quiet', action='store_true', dest='quiet', default=None, help='disable console logging') root_options.add_option('-s', '--server', action='store', dest='server', help='server fqdn/ip to connect to') root_options.add_option('-p', '--port', action='store', dest='port', help='the server port to connect on') root_options.add_option('--pid-file', action='store', dest='pid_file', help='path to pid file') root_options.add_option('--run-as', action='store', dest='process_user', help='user to run as (where applicable)') root_options.add_option('--daemonize', action='store_true', dest='daemonize', default=None, help="daemonize the process") root_options.add_option('-f', '--filter', action='store', dest='filter', help='filter string', metavar='STR') root_options.add_option('--package', action='store', dest='package', help='package name', metavar='PKG') root_options.add_option('--release', action='store', dest='release', help='rhel release version', metavar='INT') return ('root', root_options)
def options_hook(*args, **kwargs): """ Register global options. """ global_options = init_parser() global_options.add_option('--healthcheck-global-option', action ='store_true', dest='healthcheck_global_option', default=None, help='example global option' ) return ('global', global_options)
def options_hook(*args, **kwargs): """ Pass back an OptParse object, options will be merged into mirror namespace. """ options = init_parser() options.add_option('--verify', action ='store_true', dest='verify', default=None, help='Verify MD5 of files (costly)' ) return ('mirror', options)
def options_hook(*args, **kwargs): """ We can also use the options hook to tie into other plugins, or even our own. This is an alternateway of adding options for your [or other] plugins. """ my_options = init_parser() my_options.add_option('--new-local', action ='store', dest='newlocal_option', default=None, help='Example Local option' ) # return the namespace and the global options to add. return ('example', my_options)
def options_hook(*args, **kwargs): # This hook allows us to append options to the root namespace root_options = init_parser() root_options.add_option( "-R", "--root-option", action="store_true", dest="root_option", default=None, help="Example root option" ) root_options.add_option( "--json", action="store_true", dest="enable_json", default=None, help="render output as json (CLI-API)" ) root_options.add_option("--debug", action="store_true", dest="debug", default=None, help="toggle debug output") root_options.add_option("--quiet", action="store_true", dest="quiet", default=None, help="disable console logging") root_options.add_option("--test-option", action="store", dest="test_option", default=None, help="test option") return ("root", root_options)
def options_hook(*args, **kwargs): """ Use this hook to add options to other namespaces. An OptParse object is expected on return, and any options will be merged into the global options. Global options can also be used as local options by setting the config option 'merge_global_options = true' in the plugin config. """ global_options = init_parser() global_options.add_option('-G', '--global-option', action ='store_true', dest='global_option', default=None, help='Example Global option' ) # return the namespace and the global options to add. return ('global', global_options)
def options_hook(*args, **kwargs): """ Pass back an OptParse object, options will be merged into the global options. """ global_options = init_parser() global_options.add_option('--user', action ='store', dest='user', default=None, help='RHN user name' ) global_options.add_option('--pass', action='store', dest='password', default=None, help='RHN user password' ) global_options.add_option('--server', action ='store', dest='server', default=None, help='RHN server hostname' ) global_options.add_option('--port', action ='store', dest='port', default=None, help='RHN server port' ) return ('global', global_options)
class CementNamespace(object): """ Class that handles plugins and namespaces. Required Arguments: label Namespace label. Class is stored in the global 'namespaces' dict as namespaces['label']. version The version of the application. Optional Keyword Arguments: description Description of the plugin/namespace (default: '') commands A dict of command functions (default: {}) is_hidden Boolean, whether command should display in --help output (default: False) config A configobj object (default: None). A basic default config will be created if none is passed. For advanced configurations such as using a configspec or what have you can be done by passing in the configobj object. banner A version banner to display for --version (default: '') required_api The required Cement API the application was built on. (Deprecated as of 0.8.9) """ def __init__(self, label, **kw): if not label == 'root': self.version = kw.get('version', namespaces['root'].version) self.provider = kw.get('provider', namespaces['root'].config['app_module']) else: self.version = kw.get('version', None) self.provider = kw.get('provider', None) try: assert self.version, "A namespace version is required!" assert self.provider, "A namespace provider is required!" except AssertionError, error: raise CementRuntimeError, error.__str__() self.label = label self.description = kw.get('description', '') self.commands = kw.get('commands', {}) self.controller = kw.get('controller', None) self.is_hidden = kw.get('is_hidden', False) self.config = get_default_namespace_config() if kw.get('config', None): self.config.update(kw['config']) if kw.get('banner', None): self.banner = kw['banner'] else: self.banner = "%s %s version %s" % (get_config()['app_name'], self.label, self.version) self.options = kw.get('options', init_parser(banner=self.banner))