haniwers.v1.cli.main#
Main entry point for haniwers v1 CLI.
This module defines the main Typer app and registers all subcommands. Handles global options like --env, --config, --verbose, and --logfile that are shared across all commands.
Architecture: - Global callback for environment, configuration, and logging setup - Subcommands registered from separate modules (config, daq, scan) - Context object stores global configuration for subcommands - Logging configured based on global --verbose and --logfile options
Module Contents#
Functions#
Load environment variables, configure logging, and set global options. |
Data#
API#
- haniwers.v1.cli.main.app#
‘Typer(…)’
- haniwers.v1.cli.main.main(ctx: typer.Context, env_path: pathlib.Path = typer.Option(Path('.env.haniwers'), '--env', help='Path to .env file'), config_path: pathlib.Path = typer.Option(None, '--config', '-c', help='Path to config file'), verbose: bool = LoggerOptions.verbose, logfile: str = LoggerOptions.logfile, port: Optional[str] = DeviceOptions.port, baudrate: Optional[int] = DeviceOptions.baudrate, timeout: Optional[float] = DeviceOptions.timeout, device_label: Optional[str] = DeviceOptions.device_label, workspace: Optional[pathlib.Path] = OutputOptions.workspace) None#
Load environment variables, configure logging, and set global options.
This callback runs before any subcommand executes. It:
Loads environment variables from the specified .env file
Configures logging based on --verbose and --logfile options
Stores global configuration in the Typer context for subcommands to access
Args: ctx: Typer context (automatically provided) env_path: Path to environment file (.env.haniwers by default) config_path: Path to configuration TOML file (optional) verbose: Enable DEBUG level logging to stderr logfile: Optional file path to write logs to port: Serial port path (global for all commands) baudrate: Serial communication baud rate (global for all commands) timeout: Serial read timeout (global for all commands) device_label: Device identifier label (global for all commands) workspace: Output directory for data files (global for all commands)
Example: \( haniwers-v1 --verbose daq \) haniwers-v1 --logfile logs/run.log preprocess run2csv 1 \( haniwers-v1 --verbose --logfile logs/debug.log --config custom.toml daq \) haniwers-v1 --port /dev/ttyUSB0 --workspace ./output daq $ haniwers-v1 --port /dev/ttyUSB0 --baudrate 115200 threshold write --thresholds 1:290