Skip to content

Commit e152b0c

Browse files
committed
Use pathsep as delimiter for paths and allow empty initial path in autocomplete
1 parent 09b5735 commit e152b0c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

easybuild/cli/options/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# import logging
21
import os
32

43
from typing import Callable, Any
@@ -55,7 +54,7 @@ def convert(self, value, param, ctx):
5554
return res
5655

5756
def shell_complete(self, ctx, param, incomplete):
58-
others, last = ([''] + incomplete.rsplit(self.delimiter, 1))[-2:]
57+
others, last = ([None] + incomplete.rsplit(self.delimiter, 1))[-2:]
5958
# logging.warning(f"Shell completion for delimited path list: others={others}, last={last}")
6059
dir_path, prefix = os.path.split(last)
6160
dir_path = dir_path or '.'
@@ -72,7 +71,7 @@ def shell_complete(self, ctx, param, incomplete):
7271
elif os.path.isfile(full_path):
7372
if self.file_okay:
7473
possibles.append(full_path)
75-
start = f'{others}{self.delimiter}' if others else ''
74+
start = f'{others}{self.delimiter}' if others is not None else ''
7675
res = [CompletionItem(f"{start}{path}") for path in possibles]
7776
# logging.warning(f"Shell completion for delimited path list: res={possibles}")
7877
return res
@@ -105,10 +104,8 @@ class EasyconfigParam(click.ParamType):
105104
name = 'easyconfig'
106105

107106
def shell_complete(self, ctx, param, incomplete):
108-
if not incomplete:
109-
return []
110107
set_up_configuration(args=["--ignore-index"], silent=True, reconfigure=True)
111-
return [CompletionItem(ec) for ec in search_easyconfigs(fr'^{incomplete}.*\.eb$', filename_only=True)]
108+
return [CompletionItem(ec, help='') for ec in search_easyconfigs(fr'^{incomplete}.*\.eb$', filename_only=True)]
112109

113110

114111
@dataclass
@@ -150,7 +147,7 @@ def to_click_option_dec(self):
150147
kwargs['type'] = DelimitedString(delimiter=',')
151148
kwargs['multiple'] = True
152149
elif self.type in ['pathlist', 'pathtuple']:
153-
kwargs['type'] = DelimitedPathList(delimiter=',')
150+
kwargs['type'] = DelimitedPathList(delimiter=os.pathsep)
154151
kwargs['multiple'] = True
155152
elif self.type in ['urllist', 'urltuple']:
156153
kwargs['type'] = DelimitedString(delimiter='|')

0 commit comments

Comments
 (0)