# khard.cli

Command line parsing and configuration logic for khard

## Attributes

`logger` |

## Classes

`FieldsArgument` | A factory to create callable objects for add_argument's type= parameter.

## Functions

`create_parsers`(→ tuple[argparse.ArgumentParser, ...) | Create two argument parsers.
`parse_args`(→ tuple[argparse.Namespace, ...) | Parse the command line arguments and return the namespace that was
`merge_args_into_config`(→ khard.config.Config) | Merge the parsed arguments from argparse into the config object.
`init`(→ tuple[argparse.Namespace, khard.config.Config]) | Initialize khard by parsing the command line and reading the config file
`_sphinxarg_helper`() | Helper function to return the correct argument parser for the docs.

## Module Contents

khard.cli.logger

class khard.cli.FieldsArgument(*choices: str, nested: bool = False)

  A factory to create callable objects for add_argument’s type= parameter.

  The object can parse comma separated strings into list of strings, and can also check if the single elements are spelled correctly.

  _choices
  _nested = False
  __call__(argument: str) → list[str]

khard.cli.create_parsers() → tuple[argparse.ArgumentParser, argparse.ArgumentParser]

  Create two argument parsers.

  The first parser is mainly used to find the config file which can than be used to set some default values on the second parser. The second parser can parse the remainder of the command line with the subcommand and all further options and arguments.

  Returns:

    the two parsers for the first and the second parsing pass

khard.cli.parse_args(argv: list[str]) → tuple[argparse.Namespace, khard.config.Config]

  Parse the command line arguments and return the namespace that was creates by argparse.ArgumentParser.parse_args().

  Parameters:

    argv – the command line arguments

  Returns:

    the namespace parsed from the command line

khard.cli.merge_args_into_config(args: argparse.Namespace, config: khard.config.Config) → khard.config.Config

  Merge the parsed arguments from argparse into the config object.

  Parameters:

    - args – the parsed command line arguments

    - config – the parsed config file

  Returns:

    the merged config object

khard.cli.init(argv: list[str]) → tuple[argparse.Namespace, khard.config.Config]

  Initialize khard by parsing the command line and reading the config file

  Parameters:

    argv – the command line arguments

  Returns:

    the parsed command line and the fully initialized config

khard.cli._sphinxarg_helper()

  Helper function to return the correct argument parser for the docs.