diff --git a/tembo/cli.py b/tembo/cli.py index bf38f2b..ac42cb7 100644 --- a/tembo/cli.py +++ b/tembo/cli.py @@ -61,31 +61,7 @@ def new(scope, inputs, dry_run, example): _cli_verify_name_exists(scope) # get the scope information from the tembo config.yml - config_scope = {} - for option in [ - "name", - "example", - "path", - "filename", - "extension", - "template_filename", - ]: - try: - config_scope.update( - { - option: str(user_scope[option]) - for user_scope in tembo.CONFIG.scopes - if user_scope["name"] == scope - } - ) - except KeyError as key_error: - if key_error.args[0] in ["example", "template_filename"]: - config_scope.update({key_error.args[0]: None}) - continue - tembo.logger.critical( - "Key %s not found in config. yml - exiting", key_error - ) - raise SystemExit(1) from key_error + config_scope = _cli_get_config_scope(scope) # print the example to the user if example: @@ -168,6 +144,35 @@ def _cli_verify_name_exists(scope: str) -> None: raise SystemExit(1) +def _cli_get_config_scope(scope: str) -> dict: + config_scope = {} + for option in [ + "name", + "example", + "path", + "filename", + "extension", + "template_filename", + ]: + try: + config_scope.update( + { + option: str(user_scope[option]) + for user_scope in tembo.CONFIG.scopes + if user_scope["name"] == scope + } + ) + except KeyError as key_error: + if key_error.args[0] in ["example", "template_filename"]: + config_scope.update({key_error.args[0]: None}) + continue + tembo.logger.critical( + "Key %s not found in config. yml - exiting", key_error + ) + raise SystemExit(1) from key_error + return config_scope + + def cli_message(message: str) -> None: click.echo(f"[TEMBO] {message} 🐘")