niamoto.cli.commands package

Submodules

niamoto.cli.commands.base module

base.py

This module provides the base click group and common utilities for the Niamoto CLI. It defines the custom formatted CLI interface and shared command functionality.

niamoto.cli.commands.base.get_version_from_pyproject()

Gets the version number of Niamoto. First tries to get it from the installed package metadata, falls back to pyproject.toml if in development mode.

Returns:

The version string (e.g., ‘0.3.3’)

Return type:

str

class niamoto.cli.commands.base.RichCLI(name=None, commands=None, invoke_without_command=False, no_args_is_help=None, subcommand_metavar=None, chain=False, result_callback=None, **kwargs)

Bases: Group

Custom Click Group class that provides a richly formatted CLI interface. Overrides default Click Group behavior to provide custom help formatting and command organization.

Parameters:
  • name (str | None)

  • commands (cabc.MutableMapping[str, Command] | cabc.Sequence[Command] | None)

  • invoke_without_command (bool)

  • no_args_is_help (bool | None)

  • subcommand_metavar (str | None)

  • chain (bool)

  • result_callback (t.Callable[..., t.Any] | None)

  • kwargs (t.Any)

list_commands(ctx)

Return the list of command names as they were added, not sorted.

Parameters:

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

Returns:

A list of command names in the order they were added.

Return type:

list

format_help(ctx, formatter)

Override the format_help method to integrate our command table with colors.

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

  • formatter (click.HelpFormatter) – The click help formatter object.

Return type:

None

niamoto.cli.commands.base.display_next_steps()

Display the “Next Steps” section at the end of the help message.

Return type:

None

niamoto.cli.commands.base.confirm_action(question, default=False)

Ask for user confirmation before proceeding with an action.

Parameters:
  • question (str) – The question to ask

  • default (bool) – Default response if user just hits enter

Returns:

True if user confirmed, False otherwise

Return type:

bool

niamoto.cli.commands.deploy module

Commands for deploying generated content to various platforms.

Uses deployer plugins from the PluginRegistry. Configuration can come from: - deploy.yml (project config, CI/CD friendly) - CLI arguments (override deploy.yml values) - OS keyring (credentials)

niamoto.cli.commands.export module

Commands for generating exports from Niamoto data.

The export command processes targets defined in export.yml: - Each target can have its own exporter plugin (html_page_exporter, json_api_exporter, etc.) - Targets can be run individually or all at once - Groups within targets can be filtered

niamoto.cli.commands.gui module

GUI command for Niamoto CLI.

niamoto.cli.commands.imports module

Generic import commands using the entity registry and typed configurations.

niamoto.cli.commands.initialize module

Commands for initializing and resetting the Niamoto environment. Handles database initialization, configuration files and environment setup.

niamoto.cli.commands.initialize.is_directory_empty(path)

Check if a directory exists and is empty.

Parameters:

path (Path)

Return type:

bool

niamoto.cli.commands.initialize.confirm_reset()

Ask for user confirmation before resetting the environment.

Returns:

True if the user confirms, False otherwise.

Return type:

bool

niamoto.cli.commands.initialize.get_config_dir()

Retrieve the path to the configuration directory.

Returns:

Path to the configuration directory.

Return type:

str

niamoto.cli.commands.initialize.initialize_environment(config_dir, project_name, template=None)

Initialize the Niamoto environment.

Parameters:
  • config_dir (str) – Path to the configuration directory.

  • project_name (str) – Name of the project.

  • template (str, optional) – Template to use for initialization (future feature).

Return type:

None

niamoto.cli.commands.initialize.reset_environment(config_dir)

Reset the Niamoto environment.

Parameters:

config_dir (str) – Path to the configuration directory.

Return type:

None

niamoto.cli.commands.initialize.display_environment_status(config_dir)

Display the current status of the Niamoto environment.

Parameters:

config_dir (str) – Path to the configuration directory.

Return type:

None

niamoto.cli.commands.initialize.check_config_files(config_dir)

Check if the config files exist in the config directory. :param config_dir: Path to the configuration directory. :type config_dir: str

Parameters:

config_dir (str)

Return type:

None

niamoto.cli.commands.initialize.check_environment_details(config)

Check additional environment details like database, logs, and outputs.

Parameters:

config (Config) – Configuration object.

Return type:

None

niamoto.cli.commands.initialize.check_path(path, base_path, label, is_file=False)

Check if a path exists. :param path: Path to check :type path: str :param base_path: Base path :type base_path: str :param label: Label :type label: str :param is_file: If the path is a file. Defaults to False. :type is_file: bool, optional

Parameters:
  • path (str)

  • base_path (str)

  • label (str)

  • is_file (bool)

Return type:

None

niamoto.cli.commands.initialize.launch_gui()

Launch the Niamoto GUI interface after initialization.

Return type:

None

niamoto.cli.commands.optimize module

CLI command for optimizing the Niamoto database.

niamoto.cli.commands.plugins module

Plugin listing command for Niamoto CLI.

niamoto.cli.commands.run module

Command to run the complete Niamoto pipeline: import, transform, and export.

niamoto.cli.commands.stats module

Commands for displaying statistics about the Niamoto database.

niamoto.cli.commands.stats.get_general_statistics(db, registry, detailed=False)

Get general statistics about all data in the database.

Parameters:
  • db (Database)

  • registry (EntityRegistry)

  • detailed (bool)

Return type:

Dict[str, Any]

niamoto.cli.commands.stats.get_group_statistics(db, registry, group, detailed=False)

Get statistics for a specific group.

Parameters:
  • db (Database)

  • registry (EntityRegistry)

  • group (str)

  • detailed (bool)

Return type:

Dict[str, Any]

niamoto.cli.commands.stats.display_general_statistics(stats, detailed)

Display general statistics in a formatted table.

Parameters:
  • stats (Dict[str, Any])

  • detailed (bool)

Return type:

None

niamoto.cli.commands.stats.display_group_statistics(stats, group, detailed)

Display statistics for a specific group.

Parameters:
  • stats (Dict[str, Any])

  • group (str)

  • detailed (bool)

Return type:

None

niamoto.cli.commands.stats.show_data_exploration_suggestions(db, registry)

Show suggested queries and exploration tips based on the current schema.

Parameters:
  • db (Database)

  • registry (EntityRegistry)

Return type:

None

niamoto.cli.commands.stats.export_statistics(stats, filepath)

Export statistics to a file (JSON or CSV).

Parameters:
  • stats (Dict[str, Any])

  • filepath (str)

Return type:

None

niamoto.cli.commands.transform module

Commands for transforming and aggregating data in Niamoto.

Module contents

Command modules for the Niamoto CLI.

This module defines and registers all the available commands for the Niamoto command-line interface (CLI). It serves as the entry point for the CLI application, combining commands for environment initialization, data import, data processing, content generation, and deployment.

niamoto.cli.commands.create_cli()

Create and configure the main CLI group with all commands.

This function initializes the Niamoto command-line interface (CLI) by registering the following command groups:

  • init: Initializes or resets the environment.

  • import: Imports raw data into the system.

  • transforms: Transforms and aggregates raw data for analysis.

  • export: Generates static content using processed data.

  • deploy: Deploys generated content to supported platforms.

  • plugins: Lists available plugins in the system.

Returns:

The root command group for the Niamoto CLI.

Return type:

click.Group