removed duplicated code

This commit is contained in:
Aleksander W. Oleszkiewicz (Alek)
2026-07-08 20:56:06 +08:00
committed by Xubin Ren
parent f074aa7d80
commit be8ac1e484
+6 -11
View File
@@ -597,11 +597,7 @@ def onboard(
workspace: str | None = typer.Option(None, "--workspace", "-w", help="Workspace directory"), workspace: str | None = typer.Option(None, "--workspace", "-w", help="Workspace directory"),
config: str | None = typer.Option(None, "--config", "-c", help="Path to config file"), config: str | None = typer.Option(None, "--config", "-c", help="Path to config file"),
wizard: bool = typer.Option(False, "--wizard", help="Use interactive wizard"), wizard: bool = typer.Option(False, "--wizard", help="Use interactive wizard"),
refresh: bool = typer.Option( non_interactive_refresh: bool = typer.Option(False, "--refresh", help="Refresh config, preserving existing settings without prompting"),
False,
"--refresh",
help="Refresh config, preserving existing settings without prompting",
),
): ):
"""Initialize nanobot configuration and workspace.""" """Initialize nanobot configuration and workspace."""
from nanobot.config.loader import get_config_path, load_config, save_config, set_config_path from nanobot.config.loader import get_config_path, load_config, save_config, set_config_path
@@ -623,13 +619,9 @@ def onboard(
if config_path.exists(): if config_path.exists():
if wizard: if wizard:
config = _apply_workspace_override(load_config(config_path)) 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: else:
should_refresh = non_interactive_refresh
if not non_interactive_refresh:
console.print(f"[yellow]Config already exists at {config_path}[/yellow]") console.print(f"[yellow]Config already exists at {config_path}[/yellow]")
console.print( console.print(
" [bold]y[/bold] = overwrite with defaults (existing values will be lost)" " [bold]y[/bold] = overwrite with defaults (existing values will be lost)"
@@ -642,6 +634,9 @@ def onboard(
save_config(config, config_path) save_config(config, config_path)
console.print(f"[green]✓[/green] Config reset to defaults at {config_path}") console.print(f"[green]✓[/green] Config reset to defaults at {config_path}")
else: else:
should_refresh = True
if should_refresh:
config = _apply_workspace_override(load_config(config_path)) config = _apply_workspace_override(load_config(config_path))
save_config(config, config_path) save_config(config, config_path)
console.print( console.print(