Skip to content

Commit

Permalink
Merge branch 'main' into mlin-wdl2-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Jan 13, 2021
2 parents 67c8688 + 9b10917 commit 56968d0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions WDL/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
"""
Expand Down Expand Up @@ -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:"
Expand Down

0 comments on commit 56968d0

Please sign in to comment.