From 7eb9cea7662b996a8f788263f7c839fe0a042f30 Mon Sep 17 00:00:00 2001 From: nyanpasu64 Date: Sun, 19 Aug 2018 19:08:49 -0700 Subject: [PATCH] CLI: Remove --write path argument, automatically generate path If audio is present, use `audio without .wav`.yaml. If not present, default to ovgenpy.yaml. --- ovgenpy/cli.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ovgenpy/cli.py b/ovgenpy/cli.py index 2e8b1ba..e16927d 100644 --- a/ovgenpy/cli.py +++ b/ovgenpy/cli.py @@ -27,7 +27,12 @@ OutFile = click.Path(dir_okay=False) # name = possible_names[-1][1].replace('-', '_').lower() +# List of recognized Config file extensions. YAML_EXTS = ['.yaml'] +# Default extension when writing Config. +YAML_NAME = YAML_EXTS[0] +DEFAULT_CONFIG_PATH = Path('ovgenpy').with_suffix(YAML_NAME) + PROFILE_DUMP_NAME = 'cprofile' @@ -41,7 +46,7 @@ PROFILE_DUMP_NAME = 'cprofile' @click.option('--video-output', '-o', type=OutFile, help= 'Config: Output video path') # Disables GUI -@click.option('--write', '-w', nargs=1, type=OutFile, help= +@click.option('--write', '-w', is_flag=True, help= "Write config YAML file to path (don't open GUI).") @click.option('--play', '-p', is_flag=True, help= "Preview or render (don't open GUI).") @@ -54,7 +59,7 @@ def main( audio: Optional[str], video_output: Optional[str], # gui - write: Optional[str], + write: bool, play: bool, profile: bool, ): @@ -142,8 +147,13 @@ def main( raise OvgenError('GUI not implemented') else: if write: + if audio: + write_path = Path(audio).with_suffix(YAML_NAME) + else: + write_path = DEFAULT_CONFIG_PATH + # TODO test writing YAML file - yaml.dump(cfg, Path(write)) + yaml.dump(cfg, write_path) if play: if profile: