From c85a0068101c9c793e4ee5423a9374a51ad63df3 Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Sun, 24 Oct 2021 06:01:39 +0100 Subject: [PATCH] add command not found error --- tembo/cli.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/tembo/cli.py b/tembo/cli.py index 40529bf..b26acec 100644 --- a/tembo/cli.py +++ b/tembo/cli.py @@ -32,20 +32,25 @@ def new(scope, inputs, dry_run): Example: tembo new meeting my_presentation """ - for user_scope in tembo.CONFIG.scopes: - if user_scope["name"] == scope: - scoped_page = pages.ScopedPageCreator().create_page( - base_path=str(tembo.CONFIG.base_path), - page_path=str(user_scope["path"]), - filename=str(user_scope["filename"]), - extension=str(user_scope["extension"]), - name=str(user_scope["name"]), - user_input=inputs, - template_filename=str(user_scope["template_filename"]), - ) - scoped_page.save_to_disk(dry_run=dry_run) - tembo.logger.info("Saved %s to disk", scoped_page.path) - raise SystemExit(0) + _name_found = scope in [user_scope["name"] for user_scope in tembo.CONFIG.scopes] + if _name_found: + for user_scope in tembo.CONFIG.scopes: + if user_scope["name"] == scope: + scoped_page = pages.ScopedPageCreator().create_page( + base_path=str(tembo.CONFIG.base_path), + page_path=str(user_scope["path"]), + filename=str(user_scope["filename"]), + extension=str(user_scope["extension"]), + name=str(user_scope["name"]), + user_input=inputs, + template_filename=str(user_scope["template_filename"]) + ) + scoped_page.save_to_disk(dry_run=dry_run) + tembo.logger.info("Saved %s to disk", scoped_page.path) + raise SystemExit(0) + if not _name_found and len(tembo.CONFIG.scopes) > 0: + tembo.logger.warning("Command %s not found in config.yml - exiting", scope) + raise SystemExit(0) tembo.logger.critical( "No config.yml found in %s - exiting", tembo.CONFIG.config_path ) @@ -56,4 +61,6 @@ run.add_command(new) if __name__ == "__main__": - new(["scratchpad"], ()) + # BUG: fix this bug where input tokens are mismatched + new(["meeting", "robs presentation", "meeting on gcp"]) + # new(["meeting", "robs presentation"])