Skip to content

Commit

Permalink
feat(dev): add --verbose flag to deploy.py to print commands that a…
Browse files Browse the repository at this point in the history
…re executed in shell
  • Loading branch information
corneliusroemer committed Feb 26, 2024
1 parent ee122f3 commit 7c6f433
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
parser = argparse.ArgumentParser(description='Manage k3d cluster and helm installations.')
subparsers = parser.add_subparsers(dest='subcommand', required=True, help='Subcommands')
parser.add_argument('--dry-run', action='store_true', help='Print commands instead of executing them')
parser.add_argument('--verbose', action='store_true', help='Print commands that are executed')

cluster_parser = subparsers.add_parser('cluster', help='Start the k3d cluster')
cluster_parser.add_argument('--dev', action='store_true',
Expand All @@ -55,11 +56,12 @@
args = parser.parse_args()

def run_command(command: list[str], **kwargs):
if args.dry_run:
if args.dry_run or args.verbose:
if isinstance(command, str):
print(command)
else:
print(" ".join(map(str,command)))
if args.dry_run:
return subprocess.CompletedProcess(args=command, returncode=0, stdout="", stderr="")
else:
return subprocess.run(command, **kwargs)
Expand Down

0 comments on commit 7c6f433

Please sign in to comment.