|
5 | 5 | import importlib.resources as imlr |
6 | 6 | import typing |
7 | 7 | from inspect import isfunction |
| 8 | +from pathlib import Path |
8 | 9 | from types import MappingProxyType |
9 | 10 |
|
10 | 11 | import matplotlib.pyplot as plt |
@@ -83,7 +84,24 @@ def parse_args(arglist: Optional[List[str]] = None) -> Callable[[], None]: |
83 | 84 | Returns: |
84 | 85 | the function implementing the sub command to be executed. |
85 | 86 | """ |
86 | | - climan = CLIManager(conf, **SUB_CMDS) |
| 87 | + |
| 88 | + def compl_cmd() -> None: |
| 89 | + if conf.completions.zsh: |
| 90 | + filepath = Path("_stagpy.sh") |
| 91 | + print(f"writing zsh completion file {filepath}") |
| 92 | + climan.zsh_complete(filepath, "stagpy", sourceable=True) |
| 93 | + elif conf.completions.bash: |
| 94 | + filepath = Path("stagpy.sh") |
| 95 | + print(f"writing bash completion file {filepath}") |
| 96 | + climan.bash_complete(filepath, "stagpy") |
| 97 | + else: |
| 98 | + print("please choose a shell, `--help` for available options") |
| 99 | + |
| 100 | + climan = CLIManager( |
| 101 | + conf, |
| 102 | + **SUB_CMDS, |
| 103 | + completions=Subcmd("generate completion scripts", func=compl_cmd), |
| 104 | + ) |
87 | 105 |
|
88 | 106 | bash_script = CONFIG_DIR / "bash" / "stagpy.sh" |
89 | 107 | bash_script.parent.mkdir(parents=True, exist_ok=True) |
|
0 commit comments