diff --git a/WDL/CLI.py b/WDL/CLI.py index d6db59aa..28e79a4e 100644 --- a/WDL/CLI.py +++ b/WDL/CLI.py @@ -1522,6 +1522,10 @@ def fill_configure_subparser(subparsers): def configure(cfg=None, show=False, force=False, **kwargs): + if not (sys.stdin.isatty() and sys.stdout.isatty()): + die("`miniwdl configure` is for interactive use") + + from datetime import datetime import bullet from xdg import XDG_CONFIG_HOME @@ -1539,19 +1543,21 @@ def configure(cfg=None, show=False, force=False, **kwargs): if not cfg: cfg = os.path.join(XDG_CONFIG_HOME, "miniwdl.cfg") + def yes(prompt): + return bullet.Bullet(prompt=prompt, choices=["No", "Yes"]).launch() == "Yes" + if os.path.exists(cfg): assert force - logger.warn("Deleting existing configuration file at " + cfg) + logger.warn("Proceeding will overwrite existing configuration file at " + cfg) + sys.stderr.flush() + if not yes("OVERWRITE?"): + sys.exit(0) os.unlink(cfg) logger.notice("Generating configuration file at " + cfg) sys.stderr.flush() options = {} try: - - def yes(prompt): - return bullet.Bullet(prompt=prompt, choices=["No", "Yes"]).launch() == "Yes" - print( textwrap.dedent( """ @@ -1619,12 +1625,16 @@ def yes(prompt): print() sys.stdout.flush() with open(cfg, "w") as outfile: + print( + f"# miniwdl configure {miniwdl_version or '(version unknown)'} {datetime.utcnow()}Z", + file=outfile, + ) print(cfg_content, file=outfile) logger.notice("Wrote configuration file " + cfg) logger.notice("Edit the file manually to set advanced options available: ") logger.notice( " https://github.com/chanzuckerberg/miniwdl/blob/" - f"{miniwdl_version}/WDL/runtime/config_templates/default.cfg" + f"{miniwdl_version or 'main'}/WDL/runtime/config_templates/default.cfg" ) logger.notice( "Runtime environment variables may override configuration file options; see documentation:" diff --git a/tests/test_7runner.py b/tests/test_7runner.py index 4cabb449..a84789e8 100644 --- a/tests/test_7runner.py +++ b/tests/test_7runner.py @@ -798,11 +798,14 @@ def test_weird_filenames(self): runtime { container: ["ubuntu:20.04"] } +<<<<<<< HEAD hints { foo: { bar: ["bas", 42] } } +======= +>>>>>>> main } """