Skip to content

Commit e8fa6bf

Browse files
Added cfengine add/remove/search/update to add/remove/search for modules or update cfbs project
1 parent 48674ee commit e8fa6bf

3 files changed

Lines changed: 77 additions & 3 deletions

File tree

src/cfengine_cli/cfengine_wrapper/arg_parse.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,48 @@
1212

1313

1414
def parse_wrapper_args(subp: argparse._SubParsersAction):
15+
update_parser = subp.add_parser(
16+
"update",
17+
help="Updates the current cfbs project",
18+
description="A wrapper around the cfbs `update` function",
19+
)
20+
update_parser.add_argument(
21+
"to_update",
22+
nargs="*",
23+
help="Directory of cfbs-project to update",
24+
)
25+
remove_parser = subp.add_parser(
26+
"remove",
27+
help="Removes the specified module(s) from cfbs project",
28+
description="A wrapper around the cfbs `remove` function",
29+
)
30+
remove_parser.add_argument(
31+
"module",
32+
nargs="+",
33+
help="Module(s) for which to remove",
34+
)
35+
36+
add_parser = subp.add_parser(
37+
"add",
38+
help="Adds the specified module(s) to cfbs project",
39+
description="A wrapper around the cfbs `add` function",
40+
)
41+
add_parser.add_argument(
42+
"module",
43+
nargs="+",
44+
help="Module(s) for which to add",
45+
)
46+
search_parser = subp.add_parser(
47+
"search",
48+
help="Searches the build-index for specified module(s)",
49+
description="A wrapper around the cfbs `search` function",
50+
)
51+
search_parser.add_argument(
52+
"module",
53+
nargs="+",
54+
help="Module(s) for which to lookup",
55+
)
56+
1557
input_parser = subp.add_parser(
1658
"input",
1759
help="Sets/updates input.json for selected module(s)",

src/cfengine_cli/cfengine_wrapper/cfengine_commands.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
from cf_remote.commands import show as show_command
99
from cf_remote.remote import run_command, transfer_file
1010
from cf_remote.commands import connect_cmd
11-
from cfbs.commands import input_command
11+
from cfbs.commands import (
12+
input_command,
13+
add_command,
14+
remove_command,
15+
update_command,
16+
search_command,
17+
)
1218

1319
from cfengine_cli.utils import UserError
1420
from cfengine_cli.cfengine_wrapper.cfengine_objects import (
@@ -297,5 +303,21 @@ def connect(host) -> int:
297303
return connect_cmd(host)
298304

299305

300-
def cfbs_input(modules: list[str] | None = None) -> int:
306+
def cfbs_input(modules: list[str]) -> int:
301307
return input_command(modules, "cfengine input")
308+
309+
310+
def cfbs_add(modules: list[str]) -> int:
311+
return add_command(modules, "cfengine input")
312+
313+
314+
def cfbs_remove(modules: list[str] | None = None) -> int:
315+
return remove_command(modules, "cfengine input")
316+
317+
318+
def cfbs_update(to_update) -> int:
319+
return update_command(to_update)
320+
321+
322+
def cfbs_search(modules: list[str]) -> int:
323+
return search_command(modules)

src/cfengine_cli/main.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,19 @@ def run_command_with_args(args) -> int:
224224
if args.command == "build":
225225
return cfengine_commands.build(args.hub, args.non_interactive)
226226
if args.command == "deploy":
227-
return cfengine_commands.deploy(args.hub, args.masterfiles, args.non_interactive)
227+
return cfengine_commands.deploy(
228+
args.hub, args.masterfiles, args.non_interactive
229+
)
228230
if args.command == "input":
229231
return cfengine_commands.cfbs_input(args.module)
232+
if args.command == "add":
233+
return cfengine_commands.cfbs_add(args.module)
234+
if args.command == "remove":
235+
return cfengine_commands.cfbs_remove(args.module)
236+
if args.command == "search":
237+
return cfengine_commands.cfbs_search(args.module)
238+
if args.command == "update":
239+
return cfengine_commands.cfbs_update(args.to_update)
230240
if args.command == "format":
231241
return commands.format(args.files, args.line_length, args.check)
232242
if args.command == "lint":

0 commit comments

Comments
 (0)