Parses a command (string or list of args), adds the required arguments, and replaces executable with full path
(command)
| 52 | |
| 53 | |
| 54 | def _parse_command(command): |
| 55 | '''Parses a command (string or list of args), adds the required arguments, and replaces executable with full path''' |
| 56 | if isinstance(command, list): |
| 57 | args = command |
| 58 | elif isinstance(command, str): |
| 59 | args = command.split() |
| 60 | else: |
| 61 | raise ValueError(f'az command must be a string or list, not {type(command)}') |
| 62 | |
| 63 | az = shutil.which('az') |
| 64 | |
| 65 | if args[0] == 'az': |
| 66 | args.pop(0) |
| 67 | |
| 68 | if args[0] != az: |
| 69 | args = [az] + args |
| 70 | |
| 71 | return args |
| 72 | |
| 73 | |
| 74 | def cli(command, log_command=True): |