Skip to content

Commit 24008ab

Browse files
committed
Allow PLANEMO_CONDA_PREFIX to be set a default for --conda_prefix.
A few other options too that might be useful - along with a framework enhancement for options to make this easy and regular.
1 parent ca19910 commit 24008ab

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

planemo/config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def planemo_option(*args, **kwargs):
7272
"""
7373
option_type = kwargs.get("type", None)
7474
use_global_config = kwargs.pop("use_global_config", False)
75+
use_env_var = kwargs.pop("use_env_var", False)
7576

7677
if "default" in kwargs:
7778
default = kwargs.pop("default")
@@ -93,7 +94,16 @@ def callback(ctx, param, value):
9394
kwargs["callback"] = callback
9495
kwargs["default"] = None
9596

96-
return click.option(*args, **kwargs)
97+
if use_env_var:
98+
name = None
99+
for arg in args:
100+
if arg.startswith("--"):
101+
name = arg[len("--"):]
102+
assert name
103+
kwargs["envvar"] = "PLANEMO_%s" % name.upper()
104+
105+
option = click.option(*args, **kwargs)
106+
return option
97107

98108

99109
def global_config_path(config_path=None):

planemo/options.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def serve_engine_option():
4949
type=click.Choice(["galaxy", "docker_galaxy"]),
5050
default="galaxy",
5151
use_global_config=True,
52+
use_env_var=True,
5253
help=("Select an engine to serve aritfacts such as tools "
5354
"and workflows. Defaults to a local Galaxy, but running Galaxy within "
5455
"a Docker container.")
@@ -102,6 +103,7 @@ def galaxy_email_option():
102103
type=str,
103104
default="planemo@galaxyproject.org",
104105
use_global_config=True,
106+
use_env_var=True,
105107
help="E-mail address to use when launching single-user Galaxy server.",
106108
)
107109

@@ -119,6 +121,7 @@ def galaxy_database_seed_option():
119121
"--galaxy_database_seed",
120122
default=None,
121123
use_global_config=True,
124+
use_env_var=True,
122125
type=click.Path(exists=True, file_okay=True, resolve_path=True),
123126
help="Preseeded Galaxy sqlite database to target.",
124127
)
@@ -403,6 +406,7 @@ def conda_prefix_option():
403406
return planemo_option(
404407
"--conda_prefix",
405408
use_global_config=True,
409+
use_env_var=True,
406410
type=click.Path(file_okay=False, dir_okay=True),
407411
help="Conda prefix to use for conda dependency commands."
408412
)
@@ -430,6 +434,7 @@ def conda_ensure_channels_option():
430434
"--conda_ensure_channels",
431435
type=str,
432436
use_global_config=True,
437+
use_env_var=True,
433438
help=("Ensure conda is configured with specified comma separated "
434439
"list of channels."),
435440
default="r,bioconda,iuc",

0 commit comments

Comments
 (0)