diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-06-08 21:06:24 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-06-08 21:06:24 +0200 |
commit | ad0dc27337d7207ae7eb7d3e063a32132cb9a08c (patch) | |
tree | 2b14be9f964834205f873fe5d11614c7dc3a18ad /python | |
parent | 232bec0ea3309c62264cf3349f449eb251989ad3 (diff) | |
download | refcat-ad0dc27337d7207ae7eb7d3e063a32132cb9a08c.tar.gz refcat-ad0dc27337d7207ae7eb7d3e063a32132cb9a08c.zip |
cli: move to CmdlineParser
Diffstat (limited to 'python')
-rw-r--r-- | python/refcat/cli.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/python/refcat/cli.py b/python/refcat/cli.py index 042bb3d..ac308b7 100644 --- a/python/refcat/cli.py +++ b/python/refcat/cli.py @@ -88,9 +88,10 @@ def cat(*args): """ if len(args) == 0: raise ValueError("ls failed: task name required") - task_class = find_task_class(args[0]) + parser = CmdlineParser(sys.argv[2:]) + output = parser.get_task_obj().output() try: - filename = task_class().output().path + filename = output.path if filename.endswith(".zst"): subprocess.run(["zstdcat", "-T0", filename]) elif filename.endswith(".gz"): @@ -100,7 +101,7 @@ def cat(*args): except FileNotFoundError: print("file not found: {}".format(filename), file=sys.stderr) except AttributeError: - print("{} is most likely not a task object".format(name), file=sys.stderr) + print("most likely not a task object", file=sys.stderr) def ls(*args): @@ -111,7 +112,6 @@ def ls(*args): raise ValueError("ls failed: task name required") parser = CmdlineParser(sys.argv[2:]) output = parser.get_task_obj().output() - # task_class = find_task_class(args[0]) print(output.path) @@ -121,14 +121,15 @@ def ll(*args): """ if len(args) == 0: raise ValueError("ls failed: task name required") - task_class = find_task_class(args[0]) + parser = CmdlineParser(sys.argv[2:]) + output = parser.get_task_obj().output() try: - filename = task_class().output().path + filename = output.path subprocess.run(["ls", "-lah", filename]) except FileNotFoundError: print("file not found: {}".format(filename), file=sys.stderr) except AttributeError: - print("{} is most likely not a task object".format(name), file=sys.stderr) + print("most likely not a task object", file=sys.stderr) def deps(*args): @@ -137,8 +138,11 @@ def deps(*args): """ if len(args) == 0: raise ValueError("deps failed: task name required") - task_class = find_task_class(args[0]) - dump_deps(task_class()) + # task_class = find_task_class(args[0]) + # dump_deps(task_class()) + parser = CmdlineParser(sys.argv[2:]) + obj = parser.get_task_obj() + dump_deps(obj) def config(): |