diff --git a/src/primaite/utils/cli/dev_cli.py b/src/primaite/utils/cli/dev_cli.py index 886f1bf1..03567785 100644 --- a/src/primaite/utils/cli/dev_cli.py +++ b/src/primaite/utils/cli/dev_cli.py @@ -1,5 +1,3 @@ -from typing import List - import click import typer from rich import print @@ -73,44 +71,38 @@ def disable(): def config_callback( - ctx: typer.Context, - sys_log_level: Annotated[ - LogLevel, - typer.Option( - "--sys-log-level", - "-level", - click_type=click.Choice(LogLevel._member_names_, case_sensitive=False), - help="The level of system logs to output.", - show_default=False - ) - ] = None, - output_sys_logs: Annotated[ - bool, - typer.Option( - "--output-sys-logs/--no-sys-logs", - "-sys/-nsys", - help="Output system logs to file.", - show_default=False - ) - ] = None, - output_pcap_logs: Annotated[ - bool, - typer.Option( - "--output-pcap-logs/--no-pcap-logs", - "-pcap/-npcap", - help="Output network packet capture logs to file.", - show_default=False - ), - ] = None, - output_to_terminal: Annotated[ - bool, - typer.Option( - "--output-to-terminal/--no-terminal", - "-t/-nt", - help="Output system logs to terminal.", - show_default=False - ) - ] = None, + ctx: typer.Context, + sys_log_level: Annotated[ + LogLevel, + typer.Option( + "--sys-log-level", + "-level", + click_type=click.Choice(LogLevel._member_names_, case_sensitive=False), + help="The level of system logs to output.", + show_default=False, + ), + ] = None, + output_sys_logs: Annotated[ + bool, + typer.Option( + "--output-sys-logs/--no-sys-logs", "-sys/-nsys", help="Output system logs to file.", show_default=False + ), + ] = None, + output_pcap_logs: Annotated[ + bool, + typer.Option( + "--output-pcap-logs/--no-pcap-logs", + "-pcap/-npcap", + help="Output network packet capture logs to file.", + show_default=False, + ), + ] = None, + output_to_terminal: Annotated[ + bool, + typer.Option( + "--output-to-terminal/--no-terminal", "-t/-nt", help="Output system logs to terminal.", show_default=False + ), + ] = None, ): """Configure the development tools and environment.""" config_dict = get_primaite_config_dict() @@ -122,7 +114,6 @@ def config_callback( config_dict["developer_mode"]["sys_log_level"] = ctx.params.get("sys_log_level") print(f"PrimAITE dev-mode config updated sys_log_level={ctx.params.get('sys_log_level')}") - if output_sys_logs is not None: config_dict["developer_mode"]["output_sys_logs"] = output_sys_logs print(f"PrimAITE dev-mode config updated {output_sys_logs=}") @@ -150,22 +141,22 @@ dev.add_typer(config_typer) @config_typer.command() def path( - directory: Annotated[ - str, - typer.Argument( - help="Directory where the system logs and PCAP logs will be output. By default, this will be where the" - "root of the PrimAITE repository is located.", - show_default=False, - ), - ] = None, - default: Annotated[ - bool, - typer.Option( - "--default", - "-root", - help="Set PrimAITE to output system logs and pcap logs to the PrimAITE repository root.", - ), - ] = None, + directory: Annotated[ + str, + typer.Argument( + help="Directory where the system logs and PCAP logs will be output. By default, this will be where the" + "root of the PrimAITE repository is located.", + show_default=False, + ), + ] = None, + default: Annotated[ + bool, + typer.Option( + "--default", + "-root", + help="Set PrimAITE to output system logs and pcap logs to the PrimAITE repository root.", + ), + ] = None, ): """Set the output directory for the PrimAITE system and PCAP logs.""" config_dict = get_primaite_config_dict() @@ -177,9 +168,11 @@ def path( config_dict["developer_mode"]["output_dir"] = None # update application config update_primaite_config(config_dict) - print(f"PrimAITE dev-mode output_dir [medium_turquoise]" - f"{str(_PRIMAITE_ROOT.parent.parent / 'simulation_output')}" - f"[/medium_turquoise]") + print( + f"PrimAITE dev-mode output_dir [medium_turquoise]" + f"{str(_PRIMAITE_ROOT.parent.parent / 'simulation_output')}" + f"[/medium_turquoise]" + ) return if directory: diff --git a/src/primaite/utils/cli/primaite_config_utils.py b/src/primaite/utils/cli/primaite_config_utils.py index 2eb590ad..99e95bed 100644 --- a/src/primaite/utils/cli/primaite_config_utils.py +++ b/src/primaite/utils/cli/primaite_config_utils.py @@ -6,9 +6,7 @@ import yaml from primaite import PRIMAITE_PATHS -def get_primaite_config_dict( - config_path: Optional[Path] = None -) -> Dict: +def get_primaite_config_dict(config_path: Optional[Path] = None) -> Dict: """ Returns a dict containing the PrimAITE application config. diff --git a/tests/integration_tests/cli/test_dev_cli.py b/tests/integration_tests/cli/test_dev_cli.py index cd697711..fb051085 100644 --- a/tests/integration_tests/cli/test_dev_cli.py +++ b/tests/integration_tests/cli/test_dev_cli.py @@ -5,7 +5,7 @@ from pathlib import Path import pytest -from primaite import PRIMAITE_PATHS, _PRIMAITE_ROOT +from primaite import _PRIMAITE_ROOT, PRIMAITE_PATHS from primaite.utils.cli.primaite_config_utils import get_primaite_config_dict from tests.integration_tests.cli import cli