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"),
|
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,25 +619,24 @@ 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:
|
||||||
console.print(f"[yellow]Config already exists at {config_path}[/yellow]")
|
should_refresh = non_interactive_refresh
|
||||||
console.print(
|
if not non_interactive_refresh:
|
||||||
" [bold]y[/bold] = overwrite with defaults (existing values will be lost)"
|
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]N[/bold] = refresh config, keeping existing values and adding new fields"
|
)
|
||||||
)
|
console.print(
|
||||||
if typer.confirm("Overwrite?"):
|
" [bold]N[/bold] = refresh config, keeping existing values and adding new fields"
|
||||||
config = _apply_workspace_override(Config())
|
)
|
||||||
save_config(config, config_path)
|
if typer.confirm("Overwrite?"):
|
||||||
console.print(f"[green]✓[/green] Config reset to defaults at {config_path}")
|
config = _apply_workspace_override(Config())
|
||||||
else:
|
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))
|
config = _apply_workspace_override(load_config(config_path))
|
||||||
save_config(config, config_path)
|
save_config(config, config_path)
|
||||||
console.print(
|
console.print(
|
||||||
|
|||||||
Reference in New Issue
Block a user