Skip to content

Commit ddc0e26

Browse files
committed
Improve help metadata
1 parent c376375 commit ddc0e26

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

easybuild/cli/options/__init__.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
'buildpath',
4242
'containerpath',
4343
'installpath',
44-
'repositorypath',
4544
'sourcepath',
4645
]
4746

@@ -63,13 +62,14 @@ class DelimitedPathList(click.Path):
6362
"""Custom Click parameter type for delimited lists."""
6463
name = 'pathlist'
6564

66-
def __init__(self, *args, delimiter=',', resolve_full: bool = False, **kwargs):
65+
def __init__(self, *args, delimiter=',', **kwargs):
66+
self.resolve_full = kwargs.setdefault('resolve_path', False)
6767
super().__init__(*args, **kwargs)
6868
self.delimiter = delimiter
69-
self.resolve_full = resolve_full
69+
name = self.name
70+
self.name = f'[{name}[{self.delimiter}{name}]]'
7071

7172
def convert(self, value, param, ctx):
72-
# logging.warning(f"{param=} convert called with `{value=}`, `{type(value)=}`")
7373
if isinstance(value, str):
7474
res = value.split(self.delimiter)
7575
elif isinstance(value, (list, tuple)):
@@ -78,12 +78,10 @@ def convert(self, value, param, ctx):
7878
raise click.BadParameter(f"Expected a comma-separated string, got {value}")
7979
if self.resolve_full:
8080
res = [os.path.abspath(v) for v in res]
81-
# logging.warning(f"{param=} convert returning `{res=}`")
8281
return res
8382

8483
def shell_complete(self, ctx, param, incomplete):
8584
others, last = ([None] + incomplete.rsplit(self.delimiter, 1))[-2:]
86-
# logging.warning(f"Shell completion for delimited path list: others={others}, last={last}")
8785
dir_path, prefix = os.path.split(last)
8886
dir_path = dir_path or '.'
8987
# logging.warning(f"Shell completion for delimited path list: dir_path={dir_path}, prefix={prefix}")
@@ -107,11 +105,10 @@ def shell_complete(self, ctx, param, incomplete):
107105

108106
class DelimitedString(click.ParamType):
109107
"""Custom Click parameter type for delimited strings."""
110-
name = 'strlist'
111-
112108
def __init__(self, *args, delimiter=',', **kwargs):
113109
super().__init__(*args, **kwargs)
114110
self.delimiter = delimiter
111+
self.name = f'[STR[{self.delimiter}STR]]'
115112

116113
def convert(self, value, param, ctx):
117114
if isinstance(value, str):
@@ -173,20 +170,20 @@ def to_click_option_dec(self):
173170

174171
# Manually enforced FILE types
175172
if self.name in KNOWN_FILEPATH_OPTS:
176-
kwargs['type'] = click.Path(exists=True, dir_okay=False, file_okay=True)
173+
kwargs['type'] = click.Path(dir_okay=False, file_okay=True)
177174
# Manually enforced DIRECTORY types
178175
elif self.name in KNOWN_DIRPATH_OPTS:
179-
kwargs['type'] = click.Path(exists=True, dir_okay=True, file_okay=False)
176+
kwargs['type'] = click.Path(dir_okay=True, file_okay=False)
180177
# Convert options from easybuild.tools.options
181178
elif self.type in ['strlist', 'strtuple']:
182179
kwargs['type'] = DelimitedString(delimiter=',')
183-
kwargs['multiple'] = True
180+
# kwargs['multiple'] = True
184181
elif self.type in ['pathlist', 'pathtuple']:
185182
kwargs['type'] = DelimitedPathList(delimiter=os.pathsep)
186-
kwargs['multiple'] = True
183+
# kwargs['multiple'] = True
187184
elif self.type in ['urllist', 'urltuple']:
188185
kwargs['type'] = DelimitedString(delimiter='|')
189-
kwargs['multiple'] = True
186+
# kwargs['multiple'] = True
190187
elif self.type == 'choice':
191188
if self.lst is None:
192189
raise ValueError(f"Choice type requires a list of choices for option {self.name}")
@@ -202,7 +199,7 @@ def to_click_option_dec(self):
202199
if self.default is False or self.default is True:
203200
kwargs['is_flag'] = True
204201
kwargs['type'] = click.BOOL
205-
if self.action in ['store_true', 'store_false']:
202+
if self.default is True:
206203
decl = f"--{self.name}/--disable-{self.name}"
207204
elif isinstance(self.default, (list, tuple)):
208205
kwargs['multiple'] = True

0 commit comments

Comments
 (0)