How to use the jsonargparse.ArgumentParser function in jsonargparse

To help you get started, we’ve selected a few jsonargparse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Solvik / netbox_agent / netbox_agent / View on Github external
def get_config():
    p = jsonargparse.ArgumentParser(
        description="Netbox agent to run on your infrastructure's servers",
    p.add_argument('-c', '--config', action=jsonargparse.ActionConfigFile)

    p.add_argument('-r', '--register', action='store_true', help='Register server to Netbox')
    p.add_argument('-u', '--update-all', action='store_true', help='Update all infos in Netbox')
    p.add_argument('-d', '--debug', action='store_true', help='Print debug infos')
    p.add_argument('--update-network', action='store_true', help='Update network')
github omni-us / jsonargparse / View on Github external
def merge_config(cfg_from:SimpleNamespace, cfg_to:SimpleNamespace) -> SimpleNamespace:
        """Merges the first configuration into the second configuration.

            cfg_from (types.SimpleNamespace): The configuration from which to merge.
            cfg_to (types.SimpleNamespace): The configuration into which to merge.

            types.SimpleNamespace: The merged configuration.
        return dict_to_namespace(ArgumentParser._merge_config(cfg_from, cfg_to))
github omni-us / jsonargparse / View on Github external
def __init__(self, **kwargs):
        """Initializer for ActionParser instance.

            parser (ArgumentParser): A parser to parse the option with.

            ValueError: If the parser parameter is invalid.
        if 'parser' in kwargs:
            ## Runs when first initializing class by external user ##
            _check_unknown_kwargs(kwargs, {'parser'})
            self._parser = kwargs['parser']
            if not isinstance(self._parser, ArgumentParser):
                raise ValueError('Expected parser keyword argument to be an ArgumentParser.')
        elif '_parser' not in kwargs:
            raise ValueError('Expected parser keyword argument.')
            ## Runs when initialied from the __call__ method below ##
            self._parser = kwargs.pop('_parser')
            kwargs['type'] = str