@@ -34,7 +34,7 @@ def init_parser() -> argparse.ArgumentParser:
34
34
return parser
35
35
36
36
37
- def call_command (cmd : str , args : List [str ]) -> dict :
37
+ def call_command (cmd : str , args : List [str ], capture_output = False ) -> dict :
38
38
"""Execute given command.
39
39
40
40
Given command is dyanmically imported from cmd module.
@@ -44,6 +44,7 @@ def call_command(cmd: str, args: List[str]) -> dict:
44
44
params:
45
45
- cmd: command that needs to be executed.
46
46
- args: command arguments.
47
+ - capture_output: capture output of executed command on stdout and stderr.
47
48
48
49
returns:
49
50
- dict containing executed command output on output key or error on error key.
@@ -59,13 +60,13 @@ def call_command(cmd: str, args: List[str]) -> dict:
59
60
60
61
# validate if command has implement a generic execution
61
62
if hasattr (command , "generic_exec" ):
62
- return command .generic_exec (args )
63
+ return command .generic_exec (args , capture_output )
63
64
64
65
# command has different behaviour for windows/posix
65
66
os_to_function = {"nt" : "win_exec" , "posix" : "posix_exec" }
66
67
try :
67
68
call = os_to_function [os .name ]
68
- return getattr (command , call )(args )
69
+ return getattr (command , call )(args , capture_output )
69
70
except KeyError :
70
71
return {"error" : "unsuported OS" }
71
72
@@ -92,7 +93,7 @@ def get_storage(boost_data: dict, variables: List[str]) -> dict:
92
93
cmd , * args = (
93
94
boost_data ["vars" ][clean_var ].replace ("exec " , "" ).split (" " )
94
95
)
95
- cmd_output = call_command (cmd , args )
96
+ cmd_output = call_command (cmd , args , True )
96
97
if "error" in cmd_output and cmd_output ["error" ]:
97
98
return cmd_output
98
99
value = cmd_output ["output" ]
@@ -148,12 +149,7 @@ def main() -> int:
148
149
149
150
print (Fore .GREEN + f"-> [{ i + 1 } /{ total_commands } ] - { clean_cmd } " )
150
151
cmd , * args = cmd .split (" " )
151
- output = call_command (cmd , args )
152
-
153
- if "error" in output and output ["error" ]:
154
- print (Fore .RED + output ["error" ])
155
- if "output" in output and output ["output" ]:
156
- print (Fore .WHITE + output ["output" ])
152
+ call_command (cmd , args )
157
153
return 0
158
154
159
155
0 commit comments