forked from cerc-io/stack-orchestrator
More click refactoring
This commit is contained in:
1 parent
2fadafbd87
commit
397866f18b
10 files changed
+25
-17
No files matched your search
+17
-14
@@ -27,25 +27,28 @@ from decouple import config
|
||||
import subprocess
|
||||
import click
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="build the set of containers required for a complete stack",
|
||||
epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
||||
)
|
||||
parser.add_argument("--verbose", action="store_true", help="increase output verbosity")
|
||||
parser.add_argument("--quiet", action="store_true", help="don\'t print informational output")
|
||||
parser.add_argument("--check-only", action="store_true", help="looks at what\'s already there and checks if it looks good")
|
||||
parser.add_argument("--dry-run", action="store_true", help="don\'t do anything, just print the commands that would be executed")
|
||||
#parser = argparse.ArgumentParser(
|
||||
# description="build the set of containers required for a complete stack",
|
||||
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
||||
# )
|
||||
#parser.add_argument("--verbose", action="store_true", help="increase output verbosity")
|
||||
#parser.add_argument("--quiet", action="store_true", help="don\'t print informational output")
|
||||
#parser.add_argument("--check-only", action="store_true", help="looks at what\'s already there and checks if it looks good")
|
||||
#parser.add_argument("--dry-run", action="store_true", help="don\'t do anything, just print the commands that would be executed")
|
||||
|
||||
args = parser.parse_args()
|
||||
#args = parser.parse_args()
|
||||
|
||||
@click.command()
|
||||
def command():
|
||||
verbose = args.verbose
|
||||
quiet = args.quiet
|
||||
@click.pass_context
|
||||
def command(ctx):
|
||||
|
||||
quiet = ctx.obj.quiet
|
||||
verbose = ctx.obj.verbose
|
||||
dry_run = ctx.obj.verbose
|
||||
|
||||
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
|
||||
|
||||
if not args.quiet:
|
||||
if not quiet:
|
||||
print(f'Dev Root is: {dev_root_path}')
|
||||
|
||||
if not os.path.isdir(dev_root_path):
|
||||
@@ -66,7 +69,7 @@ def command():
|
||||
if not os.path.exists(build_script_filename):
|
||||
print(f"Error, script: {build_script_filename} doesn't exist")
|
||||
sys.exit(1)
|
||||
if not args.dry_run:
|
||||
if not dry_run:
|
||||
# We need to export CERC_REPO_BASE_DIR
|
||||
build_result = subprocess.run(build_script_filename, shell=True, env={'CERC_REPO_BASE_DIR':dev_root_path})
|
||||
# TODO: check result in build_result.returncode
|
||||
|
||||
Reference in new issue
Block a user