fmartingr
/
jeeves
Archived
1
0
Fork 0

Add flag to save execution (dev)

This commit is contained in:
Felipe Martin 2020-04-30 18:35:53 +02:00
parent 85a9118d0f
commit b874e9ef5a
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 8 additions and 2 deletions

View File

@ -1,9 +1,10 @@
import os.path
import time
import click
from jeeves.cli.echo import info, error, title, success
from jeeves.core.parsers import FlowParser
from jeeves.core.parsers import FlowParser, ExecutionParser
from jeeves.core.executor import Executor
from jeeves.core.registry import ActionRegistry
@ -25,7 +26,8 @@ def main():
help="Display output for flow",
)
@click.option("--argument", "-a", "defined_arguments", multiple=True, default=[])
def execute(defintinion_file, print_output, defined_arguments=list):
@click.option("--save-execution", is_flag=True, default=False, help="Store execution")
def execute(defintinion_file, print_output, save_execution, defined_arguments=list):
extension = os.path.splitext(defintinion_file.name)[1][1:]
if not hasattr(FlowParser, f"from_{extension}"):
@ -61,3 +63,7 @@ def execute(defintinion_file, print_output, defined_arguments=list):
if print_output:
click.echo(result.output)
if save_execution:
with open(f"execution.{time.time_ns()}.json", "w") as handler:
handler.write(ExecutionParser.to_json(executor._execution))