77import re
88from collections .abc import Callable
99from pathlib import Path
10- from typing import Annotated
1110
1211import typer
1312
@@ -78,6 +77,20 @@ def completer(incomplete: str) -> list[str]:
7877 return completer
7978
8079
80+ CONFIG_AUTOCOMPLETE = path_autocomplete (
81+ file_okay = True ,
82+ dir_okay = False ,
83+ match_wildcard = "*.yaml" ,
84+ readable = True ,
85+ )
86+
87+ ROOT_AUTOCOMPLETE = path_autocomplete (
88+ file_okay = False ,
89+ dir_okay = True ,
90+ writable = True ,
91+ match_wildcard = "*" ,
92+ )
93+
8194@app .command ("init" )
8295def _initialize_cli (
8396 root : Path = typer .Option (
@@ -88,9 +101,7 @@ def _initialize_cli(
88101 dir_okay = True ,
89102 writable = True ,
90103 resolve_path = True ,
91- autocompletion = path_autocomplete (
92- file_okay = False , dir_okay = True , writable = True , match_wildcard = "*"
93- ),
104+ autocompletion = ROOT_AUTOCOMPLETE ,
94105 ),
95106 force : bool = typer .Option (
96107 False ,
@@ -115,6 +126,7 @@ def _index_cli(
115126 exists = True ,
116127 file_okay = True ,
117128 readable = True ,
129+ autocompletion = CONFIG_AUTOCOMPLETE ,
118130 ),
119131 root : Path = typer .Option (
120132 Path (),
@@ -125,9 +137,7 @@ def _index_cli(
125137 dir_okay = True ,
126138 writable = True ,
127139 resolve_path = True ,
128- autocompletion = path_autocomplete (
129- file_okay = False , dir_okay = True , writable = True , match_wildcard = "*"
130- ),
140+ autocompletion = ROOT_AUTOCOMPLETE ,
131141 ),
132142 method : IndexingMethod = typer .Option (
133143 IndexingMethod .Standard .value ,
@@ -209,6 +219,7 @@ def _update_cli(
209219 exists = True ,
210220 file_okay = True ,
211221 readable = True ,
222+ autocompletion = CONFIG_AUTOCOMPLETE ,
212223 ),
213224 root : Path = typer .Option (
214225 Path (),
@@ -219,6 +230,7 @@ def _update_cli(
219230 dir_okay = True ,
220231 writable = True ,
221232 resolve_path = True ,
233+ autocompletion = ROOT_AUTOCOMPLETE ,
222234 ),
223235 method : IndexingMethod = typer .Option (
224236 IndexingMethod .Standard .value ,
@@ -296,9 +308,7 @@ def _prompt_tune_cli(
296308 dir_okay = True ,
297309 writable = True ,
298310 resolve_path = True ,
299- autocompletion = path_autocomplete (
300- file_okay = False , dir_okay = True , writable = True , match_wildcard = "*"
301- ),
311+ autocompletion = ROOT_AUTOCOMPLETE ,
302312 ),
303313 config : Path | None = typer .Option (
304314 None ,
@@ -308,9 +318,7 @@ def _prompt_tune_cli(
308318 exists = True ,
309319 file_okay = True ,
310320 readable = True ,
311- autocompletion = path_autocomplete (
312- file_okay = True , dir_okay = False , match_wildcard = "*"
313- ),
321+ autocompletion = CONFIG_AUTOCOMPLETE ,
314322 ),
315323 verbose : bool = typer .Option (
316324 False ,
@@ -442,9 +450,7 @@ def _query_cli(
442450 exists = True ,
443451 file_okay = True ,
444452 readable = True ,
445- autocompletion = path_autocomplete (
446- file_okay = True , dir_okay = False , match_wildcard = "*"
447- ),
453+ autocompletion = CONFIG_AUTOCOMPLETE ,
448454 ),
449455 data : Path | None = typer .Option (
450456 None ,
@@ -455,22 +461,18 @@ def _query_cli(
455461 dir_okay = True ,
456462 readable = True ,
457463 resolve_path = True ,
458- autocompletion = path_autocomplete (
459- file_okay = False , dir_okay = True , match_wildcard = "*"
460- ),
464+ autocompletion = ROOT_AUTOCOMPLETE ,
461465 ),
462466 root : Path = typer .Option (
463- Path . cwd (),
467+ Path (),
464468 "--root" ,
465469 "-r" ,
466470 help = "The project root directory." ,
467471 exists = True ,
468472 dir_okay = True ,
469473 writable = True ,
470474 resolve_path = True ,
471- autocompletion = path_autocomplete (
472- file_okay = False , dir_okay = True , match_wildcard = "*"
473- ),
475+ autocompletion = ROOT_AUTOCOMPLETE ,
474476 ),
475477 community_level : int = typer .Option (
476478 2 ,
0 commit comments