make exe command more robust and fix #1494 (#1495)

Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com>
This commit is contained in:
didierlopes.eth
2022-03-17 00:39:38 +00:00
committed by GitHub
parent e1cd3332cd
commit 3d2147c0b2
2 changed files with 16 additions and 3 deletions

View File

@@ -89,10 +89,14 @@ def check_path(path: str) -> str:
str:
Ratio of similarity between two strings
"""
# Just return empty path because this will be handled outside this function
if not path:
return ""
# Return string of path if such path exists
if os.path.isfile(path):
return path
logger.error("Expected list of one axis item.")
console.print("The path file provided does not exist.\n[/red]")
logger.error("The path file '%s' does not exist.", path)
console.print(f"[red]The path file '{path}' does not exist.\n[/red]")
return ""

View File

@@ -304,6 +304,13 @@ class TerminalController(BaseController):
"""Process exe command"""
# Merge rest of string path to other_args and remove queue since it is a dir
other_args += self.queue
if not other_args:
console.print(
"[red]Provide a path to the routine you wish to execute.\n[/red]"
)
return
full_input = " ".join(other_args)
if " " in full_input:
other_args_processed = full_input.split(" ")
@@ -317,7 +324,8 @@ class TerminalController(BaseController):
if path_dir in ("-i", "--input"):
args = [path_routine[1:]] + other_args_processed[idx:]
break
path_routine += f"/{path_dir}"
if path_dir not in ("-p", "--path"):
path_routine += f"/{path_dir}"
if not args:
args = [path_routine[1:]]
@@ -335,6 +343,7 @@ class TerminalController(BaseController):
dest="path",
default="",
type=check_path,
required="-h" not in args,
)
parser_exe.add_argument(
"-i",