11import os
2+ import typing as t
23
34from libtmux .server import Server
45from tmuxp import config
89
910try :
1011 import argcomplete
12+ import argcomplete .completers
1113except ImportError :
1214
1315 class ArgComplete :
@@ -24,22 +26,40 @@ def __call__(self, *args: object, **kwargs: object) -> object:
2426
2527
2628class ConfigFileCompleter (argcomplete .completers .FilesCompleter ):
27-
2829 """argcomplete completer for tmuxp files."""
2930
30- def __call__ (self , prefix , ** kwargs ):
31-
32- completion = argcomplete .completers .FilesCompleter .__call__ (
31+ def __init__ (
32+ self ,
33+ allowednames : t .Sequence [str ] = (
34+ "yml" ,
35+ "yaml" ,
36+ "json" ,
37+ ),
38+ directories : bool = False ,
39+ ** kwargs : object
40+ ):
41+ if isinstance (allowednames , (str , bytes )):
42+ allowednames = [allowednames ]
43+
44+ self .allowednames = [x .lstrip ("*" ).lstrip ("." ) for x in allowednames ]
45+ self .directories = directories
46+ # super().__init__(
47+ # self, allowednames=allowednames, directories=directories, **kwargs
48+ # )
49+
50+ def __call__ (self , prefix : str , ** kwargs ):
51+ completion : t .List [str ] = argcomplete .completers .FilesCompleter .__call__ (
3352 self , prefix , ** kwargs
3453 )
3554
36- completion += [os .path .join (config_dir , c ) for c in config .in_dir (config_dir )]
55+ completion .extend (
56+ [os .path .join (config_dir , c ) for c in config .in_dir (config_dir )]
57+ )
3758
3859 return completion
3960
4061
4162class TmuxinatorCompleter (argcomplete .completers .FilesCompleter ):
42-
4363 """argcomplete completer for Tmuxinator files."""
4464
4565 def __call__ (self , prefix , ** kwargs ):
0 commit comments