Skip to content

Commit 2acfdcd

Browse files
committed
Introduction of unc path completion for some arguments.
This patch fixes #394.
1 parent dabafcc commit 2acfdcd

File tree

1 file changed

+10
-1
lines changed
  • PyFunceble/cli/entry_points/pyfunceble

1 file changed

+10
-1
lines changed

PyFunceble/cli/entry_points/pyfunceble/cli.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,18 @@ def add_arguments_to_parser(
134134
if "dest" in opt_args:
135135
opt_args["dest"] = opt_args["dest"].replace(".", "__")
136136

137+
complete_value = opt_args.pop("complete", None)
138+
137139
for index, value in enumerate(pos_args):
138140
if value.startswith("-") and "." not in value:
139141
continue
140142

141143
pos_args[index] = value.replace(".", "__")
142144

143-
parser.add_argument(*pos_args, **opt_args)
145+
if not complete_value:
146+
parser.add_argument(*pos_args, **opt_args)
147+
else:
148+
parser.add_argument(*pos_args, **opt_args).complete = complete_value
144149

145150

146151
def get_source_group_data() -> List[Tuple[List[str], dict]]:
@@ -188,6 +193,7 @@ def get_source_group_data() -> List[Tuple[List[str], dict]]:
188193
"\nIf remote (RAW link) file is given, PyFunceble will download "
189194
"it,\n and test the content of the given RAW link as if it was a"
190195
" locally stored file.",
196+
"complete": shtab.FILE,
191197
},
192198
),
193199
(
@@ -206,6 +212,7 @@ def get_source_group_data() -> List[Tuple[List[str], dict]]:
206212
" locally stored file. "
207213
"\n\nThis argument test if an URL is available. It ONLY test "
208214
"full URLs.",
215+
"complete": shtab.FILE,
209216
},
210217
),
211218
]
@@ -1242,6 +1249,7 @@ def get_default_group_data() -> List[Tuple[List[str], dict]]:
12421249
"help": "Sets the configuration file to use. It can be a\n"
12431250
"local or remote file. Please note that this configuration can be\n"
12441251
"overwritten by your overwrite configuration file.",
1252+
"complete": shtab.FILE,
12451253
},
12461254
),
12471255
(
@@ -1252,6 +1260,7 @@ def get_default_group_data() -> List[Tuple[List[str], dict]]:
12521260
"dest": "config_dir",
12531261
"type": os.path.realpath,
12541262
"help": "Sets the configuration directory to use.",
1263+
"complete": shtab.DIRECTORY,
12551264
},
12561265
),
12571266
]

0 commit comments

Comments
 (0)