diff --git a/tenant/commands/init.py b/tenant/commands/init.py index b19c937..18c9851 100644 --- a/tenant/commands/init.py +++ b/tenant/commands/init.py @@ -15,15 +15,24 @@ def add_subparser(subparsers): def execute(args): + if args.tenant_name is not None: + tenant_name = args.tenant_name # If tenant_name is not provided and TENANT_NAME is not set, prompt the user if args.tenant_name is None and os.getenv("TENANT_NAME") is None: tenant_name = input("Please enter the tenant name: ") # Ask the user to confirm the tenant name if the environment variable is set - if os.getenv("TENANT_NAME") and args.tenant_name is not None: + if os.getenv("TENANT_NAME") == args.tenant_name: user_confirmation = input( f"Use '{os.getenv('TENANT_NAME')}' as the tenant name? (yes/no): " ).lower() + if user_confirmation not in ("yes", "y"): + tenant_name = input("Please enter the desired tenant name: ") + + if os.getenv("TENANT_NAME") and args.tenant_name != os.getenv("TENANT_NAME"): + user_confirmation = input( + f"Both env var TENANT_NAME and tenant_name argument are set. Use '{os.getenv('TENANT_NAME')}' as the tenant name? (If no, '{tenant_name}' will be used) (yes/no): " + ).lower() if user_confirmation in ("yes", "y"): tenant_name = os.getenv("TENANT_NAME")