mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 06:05:44 +00:00
adding latest to CLI
This commit is contained in:
55
tembo/cli.py
55
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} 🐘")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user