Skip to content

Commit f76c753

Browse files
authored
Merge pull request #652 from pinheadmz/run-deploy
deploy: redirect user to run if scenario was likely intent
2 parents 43831a5 + f9ea0ef commit f76c753

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/warnet/deploy.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,35 @@
3232
)
3333
from .process import stream_command
3434

35+
HINT = "\nAre you trying to run a scenario? See `warnet run --help`"
36+
3537

3638
def validate_directory(ctx, param, value):
3739
directory = Path(value)
3840
if not directory.is_dir():
39-
raise click.BadParameter(f"'{value}' is not a valid directory.")
41+
raise click.BadParameter(f"'{value}' is not a valid directory.{HINT}")
4042
if not (directory / NETWORK_FILE).exists() and not (directory / NAMESPACES_FILE).exists():
4143
raise click.BadParameter(
42-
f"'{value}' does not contain a valid network.yaml or namespaces.yaml file."
44+
f"'{value}' does not contain a valid network.yaml or namespaces.yaml file.{HINT}"
4345
)
4446
return directory
4547

4648

47-
@click.command()
49+
@click.command(context_settings={"ignore_unknown_options": True})
4850
@click.argument(
4951
"directory",
50-
type=click.Path(exists=True, file_okay=False, dir_okay=True),
52+
type=click.Path(exists=True),
5153
callback=validate_directory,
5254
)
5355
@click.option("--debug", is_flag=True)
5456
@click.option("--namespace", type=str, help="Specify a namespace in which to deploy the network")
5557
@click.option("--to-all-users", is_flag=True, help="Deploy network to all user namespaces")
56-
def deploy(directory, debug, namespace, to_all_users):
58+
@click.argument("unknown_args", nargs=-1)
59+
def deploy(directory, debug, namespace, to_all_users, unknown_args):
5760
"""Deploy a warnet with topology loaded from <directory>"""
61+
if unknown_args:
62+
raise click.BadParameter(f"Unknown args: {unknown_args}{HINT}")
63+
5864
if to_all_users:
5965
namespaces = get_namespaces_by_type(WARGAMES_NAMESPACE_PREFIX)
6066
for namespace in namespaces:

0 commit comments

Comments
 (0)