1
1
import os
2
+ import typing as t
2
3
3
4
from libtmux .server import Server
4
5
from tmuxp import config
8
9
9
10
try :
10
11
import argcomplete
12
+ import argcomplete .completers
11
13
except ImportError :
12
14
13
15
class ArgComplete :
@@ -24,22 +26,40 @@ def __call__(self, *args: object, **kwargs: object) -> object:
24
26
25
27
26
28
class ConfigFileCompleter (argcomplete .completers .FilesCompleter ):
27
-
28
29
"""argcomplete completer for tmuxp files."""
29
30
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__ (
33
52
self , prefix , ** kwargs
34
53
)
35
54
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
+ )
37
58
38
59
return completion
39
60
40
61
41
62
class TmuxinatorCompleter (argcomplete .completers .FilesCompleter ):
42
-
43
63
"""argcomplete completer for Tmuxinator files."""
44
64
45
65
def __call__ (self , prefix , ** kwargs ):
0 commit comments