Skip to content

Commit d58e6b2

Browse files
authored
patch: CLI issue for development/production setup (#513)
1 parent 9ed897e commit d58e6b2

File tree

2 files changed

+60
-34
lines changed

2 files changed

+60
-34
lines changed

cli/app/commands/install/command.py

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ def install_callback(
2222
config_file: str = typer.Option(
2323
None, "--config-file", "-c", help="Path to custom config file (defaults to built-in config)"
2424
),
25+
development: bool = typer.Option(
26+
False,
27+
"--development",
28+
"-D",
29+
help="Use development workflow (local setup, dev compose, dev env)",
30+
),
31+
dev_path: str = typer.Option(
32+
None,
33+
"--dev-path",
34+
help="Installation directory for development workflow (defaults to current directory)",
35+
),
2536
api_domain: str = typer.Option(
2637
None,
2738
"--api-domain",
@@ -34,36 +45,55 @@ def install_callback(
3445
"-vd",
3546
help="The domain where the nixopus view will be accessible (e.g. nixopus.com), if not provided you can use the ip address of the server and the port (e.g. 192.168.1.100:80)",
3647
),
37-
repo: str = typer.Option(
38-
None, "--repo", "-r", help="GitHub repository URL to clone (defaults to config value)"
39-
),
40-
branch: str = typer.Option(
41-
None, "--branch", "-b", help="Git branch to clone (defaults to config value)"
42-
),
48+
repo: str = typer.Option(None, "--repo", "-r", help="GitHub repository URL to clone (defaults to config value)"),
49+
branch: str = typer.Option(None, "--branch", "-b", help="Git branch to clone (defaults to config value)"),
4350
):
4451
"""Install Nixopus for production"""
4552
if ctx.invoked_subcommand is None:
4653
logger = Logger(verbose=verbose)
47-
install = Install(
48-
logger=logger,
49-
verbose=verbose,
50-
timeout=timeout,
51-
force=force,
52-
dry_run=dry_run,
53-
config_file=config_file,
54-
api_domain=api_domain,
55-
view_domain=view_domain,
56-
repo=repo,
57-
branch=branch,
58-
development=False,
59-
)
60-
install.run()
54+
if development:
55+
# Warn when incompatible production-only options are provided alongside --development
56+
if api_domain or view_domain:
57+
logger.warning("Ignoring --api-domain/--view-domain in development mode")
58+
dev_install = DevelopmentInstall(
59+
logger=logger,
60+
verbose=verbose,
61+
timeout=timeout,
62+
force=force,
63+
dry_run=dry_run,
64+
config_file=config_file,
65+
repo=repo,
66+
branch=branch,
67+
install_path=dev_path,
68+
)
69+
dev_install.run()
70+
else:
71+
install = Install(
72+
logger=logger,
73+
verbose=verbose,
74+
timeout=timeout,
75+
force=force,
76+
dry_run=dry_run,
77+
config_file=config_file,
78+
api_domain=api_domain,
79+
view_domain=view_domain,
80+
repo=repo,
81+
branch=branch,
82+
)
83+
install.run()
6184

6285

6386
def main_install_callback(value: bool):
6487
if value:
6588
logger = Logger(verbose=False)
66-
install = Install(logger=logger, verbose=False, timeout=300, force=False, dry_run=False, config_file=None)
89+
install = Install(
90+
logger=logger,
91+
verbose=False,
92+
timeout=300,
93+
force=False,
94+
dry_run=False,
95+
config_file=None,
96+
)
6797
install.run()
6898
raise typer.Exit()
6999

@@ -78,12 +108,8 @@ def development(
78108
config_file: str = typer.Option(
79109
None, "--config-file", "-c", help="Path to custom config file (defaults to config.dev.yaml)"
80110
),
81-
repo: str = typer.Option(
82-
None, "--repo", "-r", help="GitHub repository URL to clone (defaults to config value)"
83-
),
84-
branch: str = typer.Option(
85-
None, "--branch", "-b", help="Git branch to clone (defaults to config value)"
86-
),
111+
repo: str = typer.Option(None, "--repo", "-r", help="GitHub repository URL to clone (defaults to config value)"),
112+
branch: str = typer.Option(None, "--branch", "-b", help="Git branch to clone (defaults to config value)"),
87113
):
88114
"""Install Nixopus for local development in specified or current directory"""
89115
logger = Logger(verbose=verbose)
@@ -121,8 +147,8 @@ def ssh(
121147
timeout: int = typer.Option(10, "--timeout", "-T", help="Timeout in seconds"),
122148
):
123149
"""Generate an SSH key pair with proper permissions and optional authorized_keys integration"""
150+
logger = Logger(verbose=verbose)
124151
try:
125-
logger = Logger(verbose=verbose)
126152
config = SSHConfig(
127153
path=path,
128154
key_type=key_type,
@@ -143,10 +169,10 @@ def ssh(
143169

144170
logger.success(result.output)
145171
except TimeoutError as e:
146-
logger.error(e)
172+
logger.error(str(e))
147173
raise typer.Exit(1)
148174
except Exception as e:
149-
logger.error(e)
175+
logger.error(str(e))
150176
raise typer.Exit(1)
151177

152178

@@ -158,8 +184,8 @@ def deps(
158184
timeout: int = typer.Option(10, "--timeout", "-t", help="Timeout in seconds"),
159185
):
160186
"""Install dependencies"""
187+
logger = Logger(verbose=verbose)
161188
try:
162-
logger = Logger(verbose=verbose)
163189

164190
with TimeoutWrapper(timeout):
165191
result = install_all_deps(verbose=verbose, output=output, dry_run=dry_run)
@@ -169,8 +195,8 @@ def deps(
169195
else:
170196
logger.success("All dependencies installed successfully.")
171197
except TimeoutError as e:
172-
logger.error(e)
198+
logger.error(str(e))
173199
raise typer.Exit(1)
174200
except Exception as e:
175-
logger.error(e)
201+
logger.error(str(e))
176202
raise typer.Exit(1)

cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nixopus"
3-
version = "0.1.12"
3+
version = "0.1.13"
44
description = "A CLI for Nixopus"
55
authors = ["Nixopus <raghavyuva@gmail.com>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)