SCAutolib.cli_commands

Implementation of CLI commands for SCAutolib.

This module defines the command-line interface (CLI) for the scauto tool, utilizing the click library. It provides a user-friendly interface for system preparation, CA configuration, user setup with smart cards, and cleanup operations. Additionally, it includes a specialized command group for automated GUI testing.

Functions

check_conf_path(conf)[source]

Validates and resolves the path to the JSON configuration file.

Parameters:

conf (str) – The path string to the configuration file.

Returns:

A resolved Path object if the file exists.

Return type:

pathlib.Path

Raises:

click.BadParameter – If the path does not exist.

run_all(ctx, actions, install_missing)[source]

Executes all chained GUI test actions in the order they were provided on the command line. It initializes the graphical environment and performs specified GUI automation steps.

Parameters:
  • ctx (click.Context) – The Click context object.

  • actions (list of str) – A list of strings, where each string is a representation of a GUI test action to be performed (e.g., “init”, “assert_text:ExpectedText”).

  • install_missing (bool) – A boolean flag indicating whether any missing packages required for the graphical setup should be installed prior to running the GUI actions.

Returns:

This function does not explicitly return a value. It executes the GUI test workflow.

Return type:

None

Classes

class NaturalOrderGroup(name=None, commands=None, **attrs)[source]

A custom click.Group subclass that ensures subcommands are listed in the help output in the order they were defined in the code. This overrides click’s default alphabetical sorting for subcommands.

Initializes the NaturalOrderGroup, ensuring the commands dictionary is an OrderedDict to maintain insertion order.

Parameters:
  • name (str, optional) – The name of the command group.

  • commands (OrderedDict or dict, optional) – A dictionary of commands belonging to this group.

  • attrs (dict) – Additional attributes for the click.Group.

list_commands(ctx)[source]

Lists the command names in their defined order.

Parameters:

ctx (click.Context) – The Click context object.

Returns:

A list of command names in their defined order.

Return type:

list