Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions src/cfengine_cli/cfengine_wrapper/arg_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
add_spawn_args,
add_destroy_args,
add_connect_args,
add_list_args,
add_download_args,
)


Expand All @@ -20,6 +22,15 @@ def _add_index_arg(parser: argparse.ArgumentParser):
)


def _add_version_arg(parser: argparse.ArgumentParser):
parser.add_argument(
"--version",
"-V",
help="Specify version",
type=str,
)


def parse_wrapper_args(subp: argparse._SubParsersAction):
update_parser = subp.add_parser(
"update",
Expand Down Expand Up @@ -153,14 +164,25 @@ def parse_wrapper_args(subp: argparse._SubParsersAction):
help="Install CFEngine on the given hosts",
description="A wrapper around the cf-remote `install` function",
)
install_parser.add_argument(
"--version",
"-V",
help="Specify version",
type=str,
)
_add_version_arg(install_parser)
add_install_args(install_parser)

list_parser = subp.add_parser(
"list",
help="List CFEngine packages available for download",
description="A wrapper around the cf-remote `list` function",
)
_add_version_arg(list_parser)
add_list_args(list_parser)

download_parser = subp.add_parser(
"download",
help="Download CFEngine packages",
description="A wrapper around the cf-remote `download` function",
)
_add_version_arg(download_parser)
add_download_args(download_parser)

uninstall_parser = subp.add_parser(
"uninstall",
help="Uninstall CFEngine on the given hosts",
Expand Down
20 changes: 19 additions & 1 deletion src/cfengine_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
init_cloud_config,
install,
uninstall,
list_command,
download,
)
from cf_remote.spawn import CFRUserError, Providers
from cf_remote.validate import (
Expand Down Expand Up @@ -319,6 +321,22 @@ def run_command_with_args(args) -> int:
elif args.command == "uninstall":
all_hosts = (args.hosts or []) + (args.hub or []) + (args.clients or [])
return uninstall(all_hosts, purge=args.purge)
if args.command == "list":
return list_command(
tags=args.tags,
version=args.version,
edition=args.edition,
allow_expired=args.allow_expired,
)
if args.command == "download":
return download(
tags=args.tags,
version=args.version,
edition=args.edition,
output_dir=args.output_dir,
insecure=args.insecure,
allow_expired=args.allow_expired,
)
if args.command == "run":
return cfengine_commands.run(*args.run_args, target=args.host)
if args.command == "spawn":
Expand Down Expand Up @@ -403,7 +421,7 @@ def validate_args(args):
"Only one of '--all' or 'NAME' may be specified for destruction"
)

if args.command == "install":
if args.command in ("install", "list", "download"):
validate_edition_args(args)

if "hosts" in args and args.hosts:
Expand Down
Loading