7
7
8
8
import click
9
9
10
- from dda .cli .base import dynamic_command , ensure_features_installed
10
+ from dda .cli .base import dynamic_command , ensure_deps_installed , ensure_features_installed
11
11
from dda .config .constants import AppEnvVars
12
12
13
13
if TYPE_CHECKING :
19
19
context_settings = {"help_option_names" : [], "ignore_unknown_options" : True },
20
20
)
21
21
@click .argument ("args" , nargs = - 1 )
22
+ @click .option (
23
+ "--feat" ,
24
+ "extra_features" ,
25
+ multiple = True ,
26
+ help = """\
27
+ Extra features to install (multiple allowed).
28
+ After a feature is installed once, it will always be available.
29
+ """ ,
30
+ )
31
+ @click .option (
32
+ "--dep" ,
33
+ "extra_dependencies" ,
34
+ multiple = True ,
35
+ help = """\
36
+ Extra dependencies to install (multiple allowed).
37
+ After a dependency is installed once, it will always be available.
38
+ """ ,
39
+ )
22
40
@click .option (
23
41
"--no-dynamic-deps" ,
24
42
envvar = AppEnvVars .NO_DYNAMIC_DEPS ,
25
43
is_flag = True ,
26
44
help = "Assume required dependencies are already installed" ,
27
45
)
28
- @click .pass_obj
29
- def cmd (app : Application , * , args : tuple [str , ...], no_dynamic_deps : bool ) -> None :
46
+ @click .option (
47
+ "-h" ,
48
+ "--help" ,
49
+ "show_help" ,
50
+ is_flag = True ,
51
+ help = "Show this help message and exit" ,
52
+ )
53
+ @click .pass_context
54
+ def cmd (
55
+ ctx : click .Context ,
56
+ * ,
57
+ args : tuple [str , ...],
58
+ extra_features : tuple [str , ...],
59
+ extra_dependencies : tuple [str , ...],
60
+ no_dynamic_deps : bool ,
61
+ show_help : bool ,
62
+ ) -> None :
30
63
"""
31
64
Invoke a local task.
32
65
"""
33
66
from dda .utils .fs import Path
34
67
35
- features = ["legacy-tasks" ]
68
+ app : Application = ctx .obj
69
+
70
+ if show_help :
71
+ app .display (ctx .get_help ())
72
+ return
73
+
74
+ features = ["legacy-tasks" , * extra_features ]
36
75
invoke_args = [arg for arg in args if not arg .startswith ("-" )]
37
76
if invoke_args :
38
77
task = invoke_args [0 ]
@@ -53,4 +92,7 @@ def cmd(app: Application, *, args: tuple[str, ...], no_dynamic_deps: bool) -> No
53
92
app = app ,
54
93
prefix = str (venv .path ),
55
94
)
95
+ if extra_dependencies :
96
+ ensure_deps_installed (list (extra_dependencies ), app = app , sys_path = venv .get_sys_path (app ))
97
+
56
98
app .subprocess .replace_current_process (["python" , "-m" , "invoke" , * args ])
0 commit comments