removed duplicated code
This commit is contained in:
committed by
Xubin Ren
parent
f074aa7d80
commit
be8ac1e484
+18
-23
@@ -597,11 +597,7 @@ 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",
|
||||
),
|
||||
non_interactive_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
|
||||
@@ -623,25 +619,24 @@ 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(
|
||||
" [bold]y[/bold] = overwrite with defaults (existing values will be lost)"
|
||||
)
|
||||
console.print(
|
||||
" [bold]N[/bold] = refresh config, keeping existing values and adding new fields"
|
||||
)
|
||||
if typer.confirm("Overwrite?"):
|
||||
config = _apply_workspace_override(Config())
|
||||
save_config(config, config_path)
|
||||
console.print(f"[green]✓[/green] Config reset to defaults at {config_path}")
|
||||
else:
|
||||
should_refresh = non_interactive_refresh
|
||||
if not non_interactive_refresh:
|
||||
console.print(f"[yellow]Config already exists at {config_path}[/yellow]")
|
||||
console.print(
|
||||
" [bold]y[/bold] = overwrite with defaults (existing values will be lost)"
|
||||
)
|
||||
console.print(
|
||||
" [bold]N[/bold] = refresh config, keeping existing values and adding new fields"
|
||||
)
|
||||
if typer.confirm("Overwrite?"):
|
||||
config = _apply_workspace_override(Config())
|
||||
save_config(config, config_path)
|
||||
console.print(f"[green]✓[/green] Config reset to defaults at {config_path}")
|
||||
else:
|
||||
should_refresh = True
|
||||
|
||||
if should_refresh:
|
||||
config = _apply_workspace_override(load_config(config_path))
|
||||
save_config(config, config_path)
|
||||
console.print(
|
||||
|
||||
Reference in New Issue
Block a user