Add descriptions for zsh completions
@@ -6,7 +6,7 @@ type CommandInfo = {
description: string;
options: string[];
subcommands: CommandInfo[];
-}
+};
function commandInfo(cmd: Command): CommandInfo {
return {
@@ -17,26 +17,34 @@ function commandInfo(cmd: Command): CommandInfo {
};
}
-function completion(env: any, info: CommandInfo) {
+function completer(env: any, info: CommandInfo) {
if (!env.complete) return;
if (env.prev == info.command) {
- tabtab.log(info.subcommands.map(subcmd => subcmd.command));
+ tabtab.log(
+ info.subcommands.map((subcmd) => {
+ return {
+ name: subcmd.command,
+ description: subcmd.description
+ };
+ })
+ );
tabtab.log(info.options);
return;
}
- info.subcommands.map(subcmd => completion(env, subcmd));
+ info.subcommands.map((subcmd) => completer(env, subcmd));
}
export function command(program: Command) {
- const complete = new Command('completion')
+ // prettier-ignore
+ const completion = new Command('completion')
.description('generate shell completion scripts')
.action(() => {
const env = tabtab.parseEnv(process.env);
const info = commandInfo(program);
- return completion(env, info);
+ return completer(env, info);
});
- complete
+ completion
.command('install')
.description('install shell completions for zk')
.action(async () => {
@@ -46,12 +54,12 @@ export function command(program: Command) {
});
});
- complete
+ completion
.command('uninstall')
.description('uninstall shell completions for zk')
.action(async () => {
await tabtab.uninstall({ name: 'zk' });
});
- return complete;
+ return completion;
}
