smah.smah

smah.py

This module serves as the entry point for the SMAH Command Line Tool. It is responsible for parsing command line arguments, initializing settings, and coordinating execution based on user inputs. The module utilizes the argparse library for command-line argument parsing and rich for enhanced console outputs.

Classes and Functions: - extract_args: Parses and extracts command-line arguments. - log_settings: Logs current application settings using rich. - main: The primary function that sets up application configuration and executes user-specified queries.

Dependencies: - os, argparse, textwrap, and yaml for OS operations, argument parsing, text manipulation, and YAML operations. - rich for enhanced console outputs, utilized throughout the module for logging and interactive feedback. - smah.settings.Settings and smah.runner.Runner, which are the other core modules facilitating configuration handling and executing user queries.

Use Cases: - Can be run with flags to execute specific instructions or queries, configure settings, and manage output verbosity.

Note: Ensure the environment is set up with the necessary dependencies before executing this script.

Functions

init_database(args)

Initializes the database connection.

main()

The primary function that sets up application configuration and executes user-specified queries.

pick_session(args)

Picks a recent session from the database.

resume_session(args[, session])

Resumes the last conversation from the database.

smah.smah.init_database(args)[source]

Initializes the database connection.

Parameters:

args (argparse.Namespace) – The parsed command-line arguments.

smah.smah.main()[source]

The primary function that sets up application configuration and executes user-specified queries.

This function configures logging, parses command-line arguments, initializes settings, and coordinates the execution based on user inputs. It handles different modes of operation such as processing queries, processing instructions from a file, or running in interactive mode.

Raises:

Exception – If an unexpected error occurs during execution.

smah.smah.pick_session(args) int[source]

Picks a recent session from the database.

smah.smah.resume_session(args, session: int | None = None)[source]

Resumes the last conversation from the database.

Parameters:

args (argparse.Namespace) – The parsed command-line arguments.