From f074aa7d808503839877893040872d8e34303376 Mon Sep 17 00:00:00 2001 From: "Aleksander W. Oleszkiewicz (Alek)" Date: Wed, 8 Jul 2026 10:25:22 +0200 Subject: [PATCH] feat: add --refresh flag to onboard command for non-interactive config updates --- nanobot/cli/commands.py | 11 +++++++++++ tests/cli/test_commands.py | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 0a35fc9a..4ed4f314 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -597,6 +597,11 @@ def onboard( workspace: str | None = typer.Option(None, "--workspace", "-w", help="Workspace directory"), config: str | None = typer.Option(None, "--config", "-c", help="Path to config file"), wizard: bool = typer.Option(False, "--wizard", help="Use interactive wizard"), + refresh: bool = typer.Option( + False, + "--refresh", + help="Refresh config, preserving existing settings without prompting", + ), ): """Initialize nanobot configuration and workspace.""" from nanobot.config.loader import get_config_path, load_config, save_config, set_config_path @@ -618,6 +623,12 @@ def onboard( if config_path.exists(): if wizard: config = _apply_workspace_override(load_config(config_path)) + elif refresh: + config = _apply_workspace_override(load_config(config_path)) + save_config(config, config_path) + console.print( + f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)" + ) else: console.print(f"[yellow]Config already exists at {config_path}[/yellow]") console.print( diff --git a/tests/cli/test_commands.py b/tests/cli/test_commands.py index 48936914..160835c8 100644 --- a/tests/cli/test_commands.py +++ b/tests/cli/test_commands.py @@ -218,6 +218,20 @@ def test_onboard_existing_config_refresh(mock_paths): assert (workspace_dir / "AGENTS.md").exists() +def test_onboard_existing_config_refresh_non_interactive(mock_paths): + """Config exists, user specifies --refresh — should refresh non-interactively (no prompt).""" + config_file, workspace_dir, _ = mock_paths + config_file.write_text('{"existing": true}') + + result = runner.invoke(app, ["onboard", "--refresh"]) + + assert result.exit_code == 0 + assert "Config already exists" not in result.stdout + assert "existing values preserved" in result.stdout + assert workspace_dir.exists() + assert (workspace_dir / "AGENTS.md").exists() + + def test_onboard_existing_config_overwrite(mock_paths): """Config exists, user confirms overwrite — should reset to defaults.""" config_file, workspace_dir, _ = mock_paths @@ -261,6 +275,7 @@ def test_onboard_help_shows_workspace_and_config_options(): assert "--config" in stripped_output assert "-c" in stripped_output assert "--wizard" in stripped_output + assert "--refresh" in stripped_output assert "--dir" not in stripped_output