onyo.lib.command_utils module

onyo.lib.command_utils.allowed_config_args(git_config_args)[source]

Check a list of arguments for disallowed git config flags.

git-config stores configuration information in a variety of locations. This makes sure that such location flags aren’t in the list (and --help).

A helper for the onyo config command.

Parameters:

git_config_args (list[str]) – The list of arguments to pass to git config.

Raises:

ValueError – If a disallowed flag is detected.

Return type:

bool

onyo.lib.command_utils.get_history_cmd(interactive, repo)[source]

Get the command to display history.

The command is selected according to the (non)interactive mode, and which verifies that it exists.

A helper for the onyo history command.

Parameters:
  • interactive (bool) – Whether the CLI mode is interactive or not.

  • repo (OnyoRepo) – The OnyoRepo to search through for the configuration.

Raises:

ValueError – If the configuration key is either not set or the configured history program cannot be found by which.

Return type:

str

onyo.lib.command_utils.natural_sort(assets, keys)[source]

Sort an asset list by a list of keys.

Parameters:
  • assets (list[dict | UserDict]) – Assets to sort.

  • keys (dict[str, Literal['ascending', 'descending']]) – Keys to sort assets by.

  • reverse – Whether to sort in reverse order.

Return type:

list[dict | UserDict]

onyo.lib.command_utils.print_diff(diffable)[source]
Return type:

None