@seedcli/completions 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/bash.d.ts +6 -0
- package/dist/bash.d.ts.map +1 -0
- package/dist/bash.js +68 -0
- package/dist/bash.js.map +1 -0
- package/dist/detect.d.ts +6 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +17 -0
- package/dist/detect.js.map +1 -0
- package/dist/fish.d.ts +6 -0
- package/dist/fish.d.ts.map +1 -0
- package/dist/fish.js +53 -0
- package/dist/fish.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +9 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +45 -0
- package/dist/install.js.map +1 -0
- package/dist/powershell.d.ts +6 -0
- package/dist/powershell.d.ts.map +1 -0
- package/dist/powershell.js +63 -0
- package/dist/powershell.js.map +1 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/zsh.d.ts +6 -0
- package/dist/zsh.d.ts.map +1 -0
- package/dist/zsh.js +86 -0
- package/dist/zsh.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Seed CLI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/bash.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../src/bash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,YAAY,CAAC;AAyCpE;;GAEG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAiCjD"}
|
package/dist/bash.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function generateCommandCase(brand, cmd, path) {
|
|
2
|
+
const lines = [];
|
|
3
|
+
const casePattern = path ? `${path}_${cmd.name}` : cmd.name;
|
|
4
|
+
// Gather completions for this command
|
|
5
|
+
const words = [];
|
|
6
|
+
// Add subcommands
|
|
7
|
+
if (cmd.subcommands) {
|
|
8
|
+
for (const sub of cmd.subcommands) {
|
|
9
|
+
words.push(sub.name);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// Add flags
|
|
13
|
+
if (cmd.flags) {
|
|
14
|
+
for (const f of cmd.flags) {
|
|
15
|
+
words.push(`--${f.name}`);
|
|
16
|
+
if (f.alias)
|
|
17
|
+
words.push(`-${f.alias}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (words.length > 0) {
|
|
21
|
+
lines.push(` ${casePattern})`);
|
|
22
|
+
lines.push(` COMPREPLY=( $(compgen -W "${words.join(" ")}" -- "\${cur}") )`);
|
|
23
|
+
lines.push(" return 0");
|
|
24
|
+
lines.push(" ;;");
|
|
25
|
+
}
|
|
26
|
+
// Recurse for subcommands
|
|
27
|
+
if (cmd.subcommands) {
|
|
28
|
+
for (const sub of cmd.subcommands) {
|
|
29
|
+
lines.push(generateCommandCase(brand, sub, casePattern));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return lines.join("\n");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate a bash completion script.
|
|
36
|
+
*/
|
|
37
|
+
export function bash(info) {
|
|
38
|
+
const { brand, commands } = info;
|
|
39
|
+
const topLevelWords = commands.flatMap((c) => [c.name, ...(c.aliases ?? [])]).join(" ");
|
|
40
|
+
const caseClauses = [];
|
|
41
|
+
for (const cmd of commands) {
|
|
42
|
+
caseClauses.push(generateCommandCase(brand, cmd, ""));
|
|
43
|
+
}
|
|
44
|
+
return `# Bash completions for ${brand}
|
|
45
|
+
# Generated by @seedcli/completions
|
|
46
|
+
|
|
47
|
+
_${brand}_completions() {
|
|
48
|
+
local cur prev words cword
|
|
49
|
+
_init_completion || return
|
|
50
|
+
|
|
51
|
+
if [[ \${cword} -eq 1 ]]; then
|
|
52
|
+
COMPREPLY=( $(compgen -W "${topLevelWords}" -- "\${cur}") )
|
|
53
|
+
return 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
local command="\${words[1]}"
|
|
57
|
+
|
|
58
|
+
case "\${command}" in
|
|
59
|
+
${caseClauses.join("\n")}
|
|
60
|
+
*)
|
|
61
|
+
;;
|
|
62
|
+
esac
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
complete -F _${brand}_completions ${brand}
|
|
66
|
+
`;
|
|
67
|
+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CAWlC"}
|
package/dist/detect.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect the current shell from environment variables.
|
|
3
|
+
*/
|
|
4
|
+
export function detect() {
|
|
5
|
+
const shell = process.env.SHELL ?? "";
|
|
6
|
+
if (shell.includes("zsh"))
|
|
7
|
+
return "zsh";
|
|
8
|
+
if (shell.includes("fish"))
|
|
9
|
+
return "fish";
|
|
10
|
+
if (shell.includes("bash"))
|
|
11
|
+
return "bash";
|
|
12
|
+
// Check for PowerShell via PSModulePath
|
|
13
|
+
if (process.env.PSModulePath)
|
|
14
|
+
return "powershell";
|
|
15
|
+
return "bash";
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,MAAM;IACrB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;IAEtC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC1C,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE1C,wCAAwC;IACxC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY;QAAE,OAAO,YAAY,CAAC;IAElD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/dist/fish.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fish.d.ts","sourceRoot":"","sources":["../src/fish.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,YAAY,CAAC;AAiDpE;;GAEG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAejD"}
|
package/dist/fish.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function generateFishCompletions(brand, cmd, condition) {
|
|
2
|
+
const lines = [];
|
|
3
|
+
const desc = cmd.description ? ` -d '${cmd.description.replace(/'/g, "'\\''")}'` : "";
|
|
4
|
+
// Add the command itself as a completion
|
|
5
|
+
lines.push(`complete -c ${brand} ${condition} -a '${cmd.name}'${desc}`);
|
|
6
|
+
// Add aliases
|
|
7
|
+
if (cmd.aliases) {
|
|
8
|
+
for (const alias of cmd.aliases) {
|
|
9
|
+
lines.push(`complete -c ${brand} ${condition} -a '${alias}'${desc}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// Subcommand condition: we need the parent command in the args
|
|
13
|
+
const subCondition = `-n '__fish_seen_subcommand_from ${cmd.name}'`;
|
|
14
|
+
// Add flags for this command
|
|
15
|
+
if (cmd.flags) {
|
|
16
|
+
for (const f of cmd.flags) {
|
|
17
|
+
const flagDesc = f.description ? ` -d '${f.description.replace(/'/g, "'\\''")}'` : "";
|
|
18
|
+
let line = `complete -c ${brand} ${subCondition} -l '${f.name}'`;
|
|
19
|
+
if (f.alias) {
|
|
20
|
+
line += ` -s '${f.alias}'`;
|
|
21
|
+
}
|
|
22
|
+
if (f.choices && f.choices.length > 0) {
|
|
23
|
+
line += ` -r -a '${f.choices.join(" ")}'`;
|
|
24
|
+
}
|
|
25
|
+
line += flagDesc;
|
|
26
|
+
lines.push(line);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Recurse for subcommands
|
|
30
|
+
if (cmd.subcommands) {
|
|
31
|
+
for (const sub of cmd.subcommands) {
|
|
32
|
+
lines.push(...generateFishCompletions(brand, sub, subCondition));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return lines;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate fish completion commands.
|
|
39
|
+
*/
|
|
40
|
+
export function fish(info) {
|
|
41
|
+
const { brand, commands } = info;
|
|
42
|
+
const lines = [
|
|
43
|
+
`# Fish completions for ${brand}`,
|
|
44
|
+
`# Generated by @seedcli/completions`,
|
|
45
|
+
"",
|
|
46
|
+
];
|
|
47
|
+
const topLevelCondition = `-n 'not __fish_seen_subcommand_from ${commands.map((c) => c.name).join(" ")}'`;
|
|
48
|
+
for (const cmd of commands) {
|
|
49
|
+
lines.push(...generateFishCompletions(brand, cmd, topLevelCondition));
|
|
50
|
+
}
|
|
51
|
+
return `${lines.join("\n")}\n`;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=fish.js.map
|
package/dist/fish.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fish.js","sourceRoot":"","sources":["../src/fish.ts"],"names":[],"mappings":"AAEA,SAAS,uBAAuB,CAC/B,KAAa,EACb,GAAsB,EACtB,SAAiB;IAEjB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtF,yCAAyC;IACzC,KAAK,CAAC,IAAI,CAAC,eAAe,KAAK,IAAI,SAAS,QAAQ,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAExE,cAAc;IACd,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACjB,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,eAAe,KAAK,IAAI,SAAS,QAAQ,KAAK,IAAI,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;IACF,CAAC;IAED,+DAA+D;IAC/D,MAAM,YAAY,GAAG,mCAAmC,GAAG,CAAC,IAAI,GAAG,CAAC;IAEpE,6BAA6B;IAC7B,IAAI,GAAG,C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AuC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAE1G,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAChC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { bash } from "./bash.js";
|
|
2
|
+
export { detect } from "./detect.js";
|
|
3
|
+
export { fish } from "./fish.js";
|
|
4
|
+
export { install } from "./install.js";
|
|
5
|
+
export { powershell } from "./powershell.js";
|
|
6
|
+
export type { CompletionArg, CompletionCommand, CompletionFlag, CompletionInfo, ShellType, } from "./types.js";
|
|
7
|
+
export { zsh } from "./zsh.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EACX,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,SAAS,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { bash } from "./bash.js";
|
|
2
|
+
export { detect } from "./detect.js";
|
|
3
|
+
export { fish } from "./fish.js";
|
|
4
|
+
export { install } from "./install.js";
|
|
5
|
+
export { powershell } from "./powershell.js";
|
|
6
|
+
export { zsh } from "./zsh.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CompletionInfo, ShellType } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Auto-detect shell, generate completion script, and install to the appropriate rc file.
|
|
4
|
+
*/
|
|
5
|
+
export declare function install(info: CompletionInfo, shell?: ShellType): Promise<{
|
|
6
|
+
shell: ShellType;
|
|
7
|
+
path: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA8B5D;;GAEG;AACH,wBAAsB,OAAO,CAC5B,IAAI,EAAE,cAAc,EACpB,KAAK,CAAC,EAAE,SAAS,GACf,OAAO,CAAC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAe7C"}
|
package/dist/install.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { bash } from "./bash.js";
|
|
4
|
+
import { detect } from "./detect.js";
|
|
5
|
+
import { fish } from "./fish.js";
|
|
6
|
+
import { powershell } from "./powershell.js";
|
|
7
|
+
import { zsh } from "./zsh.js";
|
|
8
|
+
const { appendFile, mkdir } = await import("node:fs/promises");
|
|
9
|
+
const GENERATORS = {
|
|
10
|
+
bash,
|
|
11
|
+
zsh,
|
|
12
|
+
fish,
|
|
13
|
+
powershell,
|
|
14
|
+
};
|
|
15
|
+
function getRcPath(shell, brand) {
|
|
16
|
+
const home = homedir();
|
|
17
|
+
switch (shell) {
|
|
18
|
+
case "bash":
|
|
19
|
+
return join(home, ".bashrc");
|
|
20
|
+
case "zsh":
|
|
21
|
+
return join(home, ".zshrc");
|
|
22
|
+
case "fish":
|
|
23
|
+
return join(home, ".config", "fish", "completions", `${brand}.fish`);
|
|
24
|
+
case "powershell":
|
|
25
|
+
return (process.env.PROFILE ??
|
|
26
|
+
join(home, ".config", "powershell", "Microsoft.PowerShell_profile.ps1"));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Auto-detect shell, generate completion script, and install to the appropriate rc file.
|
|
31
|
+
*/
|
|
32
|
+
export async function install(info, shell) {
|
|
33
|
+
const detectedShell = shell ?? detect();
|
|
34
|
+
const script = GENERATORS[detectedShell](info);
|
|
35
|
+
const rcPath = getRcPath(detectedShell, info.brand);
|
|
36
|
+
// Ensure parent directory exists for fish
|
|
37
|
+
if (detectedShell === "fish") {
|
|
38
|
+
const dir = join(homedir(), ".config", "fish", "completions");
|
|
39
|
+
await mkdir(dir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
const marker = `# ${info.brand} completions`;
|
|
42
|
+
await appendFile(rcPath, `\n${marker}\n${script}\n`);
|
|
43
|
+
return { shell: detectedShell, path: rcPath };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,KAAK,UAAU,OAAO,CAC5B,IAAoB,EACpB,KAAiB;IAEjB,MAAM,aAAa,GAAG,KAAK,IAAI,MAAM,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAEpD,0CAA0C;IAC1C,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;QAC9D,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,cAAc,CAAC;IAC7C,MAAM,UAAU,CAAC,MAAM,EAAE,KAAK,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC;IAErD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../src/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,YAAY,CAAC;AAiCpE;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAwCvD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
function generateCommandCompletions(cmd, indent) {
|
|
2
|
+
const lines = [];
|
|
3
|
+
// Add subcommands
|
|
4
|
+
if (cmd.subcommands) {
|
|
5
|
+
for (const sub of cmd.subcommands) {
|
|
6
|
+
const desc = sub.description ? sub.description.replace(/'/g, "''") : sub.name;
|
|
7
|
+
lines.push(`${indent}[CompletionResult]::new('${sub.name}', '${desc}', [CompletionResultType]::ParameterValue, '${desc}')`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
// Add flags
|
|
11
|
+
if (cmd.flags) {
|
|
12
|
+
for (const f of cmd.flags) {
|
|
13
|
+
const desc = f.description ? f.description.replace(/'/g, "''") : `--${f.name}`;
|
|
14
|
+
lines.push(`${indent}[CompletionResult]::new('--${f.name}', '${desc}', [CompletionResultType]::ParameterName, '${desc}')`);
|
|
15
|
+
if (f.alias) {
|
|
16
|
+
lines.push(`${indent}[CompletionResult]::new('-${f.alias}', '${desc}', [CompletionResultType]::ParameterName, '${desc}')`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return lines;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate a PowerShell `Register-ArgumentCompleter` script.
|
|
24
|
+
*/
|
|
25
|
+
export function powershell(info) {
|
|
26
|
+
const { brand, commands } = info;
|
|
27
|
+
const commandCases = [];
|
|
28
|
+
for (const cmd of commands) {
|
|
29
|
+
const completions = generateCommandCompletions(cmd, " ");
|
|
30
|
+
if (completions.length > 0) {
|
|
31
|
+
commandCases.push(` '${cmd.name}' {
|
|
32
|
+
${completions.join("\n")}
|
|
33
|
+
}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const topLevelCompletions = commands
|
|
37
|
+
.map((c) => {
|
|
38
|
+
const desc = c.description ? c.description.replace(/'/g, "''") : c.name;
|
|
39
|
+
return ` [CompletionResult]::new('${c.name}', '${desc}', [CompletionResultType]::ParameterValue, '${desc}')`;
|
|
40
|
+
})
|
|
41
|
+
.join("\n");
|
|
42
|
+
return `# PowerShell completions for ${brand}
|
|
43
|
+
# Generated by @seedcli/completions
|
|
44
|
+
|
|
45
|
+
Register-ArgumentCompleter -CommandName '${brand}' -ScriptBlock {
|
|
46
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
47
|
+
|
|
48
|
+
$tokens = $commandAst.ToString().Split(' ', [StringSplitOptions]::RemoveEmptyEntries)
|
|
49
|
+
|
|
50
|
+
if ($tokens.Length -le 1) {
|
|
51
|
+
${topLevelCompletions}
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
$command = $tokens[1]
|
|
56
|
+
|
|
57
|
+
switch ($command) {
|
|
58
|
+
${commandCases.join("\n")}
|
|
59
|
+
}
|
|
60
|
+
} | Where-Object { $_.CompletionText -like "$wordToComplete*" }
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=powershell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"powershell.js","sourceRoot":"","sources":["../src/powershell.ts"],"names":[],"mappings":"AAEA,SAAS,0BAA0B,CAAC,GAAsB,EAAE,MAAc;IACzE,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,kBAAkB;IAClB,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;QACrB,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;YAC9E,KAAK,CAAC,IAAI,CACT,GAAG,MAAM,4BAA4B,GAAG,CAAC,IAAI,OAAO,IAAI,+CAA+C,IAAI,IAAI,CAC/G,CAAC;QACH,CAAC;IACF,CAAC;IAED,YAAY;IACZ,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACf,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;YA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EAOnB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;CAGxB,CAAC;AACF,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ShellType = "bash" | "zsh" | "fish" | "powershell";
|
|
2
|
+
export interface CompletionFlag {
|
|
3
|
+
name: string;
|
|
4
|
+
alias?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
type: string;
|
|
7
|
+
choices?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface CompletionArg {
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
choices?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
export interface CompletionCommand {
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
aliases?: string[];
|
|
18
|
+
subcommands?: CompletionCommand[];
|
|
19
|
+
flags?: CompletionFlag[];
|
|
20
|
+
args?: CompletionArg[];
|
|
21
|
+
}
|
|
22
|
+
export interface CompletionInfo {
|
|
23
|
+
brand: string;
|
|
24
|
+
commands: CompletionCommand[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,YAAY,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,aAAa,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC9B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/zsh.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zsh.d.ts","sourceRoot":"","sources":["../src/zsh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,YAAY,CAAC;AAyDpE;;GAEG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAsChD"}
|
package/dist/zsh.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function generateSubcommandFunction(brand, cmd, prefix) {
|
|
2
|
+
const blocks = [];
|
|
3
|
+
const fnName = prefix ? `_${brand}_${prefix}_${cmd.name}` : `_${brand}_${cmd.name}`;
|
|
4
|
+
const args = [];
|
|
5
|
+
// Add subcommand descriptions
|
|
6
|
+
if (cmd.subcommands && cmd.subcommands.length > 0) {
|
|
7
|
+
const subcmdDescs = cmd.subcommands
|
|
8
|
+
.map((s) => `'${s.name}:${(s.description ?? "").replace(/'/g, "'\\''")}'`)
|
|
9
|
+
.join(" ");
|
|
10
|
+
args.push(`'1:command:(${cmd.subcommands.map((s) => s.name).join(" ")})'`);
|
|
11
|
+
blocks.push(`# Subcommands: ${subcmdDescs}`);
|
|
12
|
+
}
|
|
13
|
+
// Add flags
|
|
14
|
+
if (cmd.flags) {
|
|
15
|
+
for (const f of cmd.flags) {
|
|
16
|
+
const desc = (f.description ?? "")
|
|
17
|
+
.replace(/'/g, "'\\''")
|
|
18
|
+
.replace(/\[/g, "\\[")
|
|
19
|
+
.replace(/\]/g, "\\]");
|
|
20
|
+
if (f.choices && f.choices.length > 0) {
|
|
21
|
+
args.push(`'--${f.name}[${desc}]:value:(${f.choices.join(" ")})'`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
args.push(`'--${f.name}[${desc}]'`);
|
|
25
|
+
}
|
|
26
|
+
if (f.alias) {
|
|
27
|
+
args.push(`'-${f.alias}[${desc}]'`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
blocks.push(`${fnName}() {`);
|
|
32
|
+
blocks.push(" _arguments \\");
|
|
33
|
+
for (let i = 0; i < args.length; i++) {
|
|
34
|
+
blocks.push(` ${args[i]}${i < args.length - 1 ? " \\" : ""}`);
|
|
35
|
+
}
|
|
36
|
+
blocks.push("}");
|
|
37
|
+
// Recurse for subcommands
|
|
38
|
+
if (cmd.subcommands) {
|
|
39
|
+
for (const sub of cmd.subcommands) {
|
|
40
|
+
const nextPrefix = prefix ? `${prefix}_${cmd.name}` : cmd.name;
|
|
41
|
+
blocks.push(...generateSubcommandFunction(brand, sub, nextPrefix));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return blocks;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generate a zsh completion script using `#compdef`.
|
|
48
|
+
*/
|
|
49
|
+
export function zsh(info) {
|
|
50
|
+
const { brand, commands } = info;
|
|
51
|
+
const functionBlocks = [];
|
|
52
|
+
for (const cmd of commands) {
|
|
53
|
+
functionBlocks.push(...generateSubcommandFunction(brand, cmd, ""));
|
|
54
|
+
}
|
|
55
|
+
return `#compdef ${brand}
|
|
56
|
+
# Zsh completions for ${brand}
|
|
57
|
+
# Generated by @seedcli/completions
|
|
58
|
+
|
|
59
|
+
_${brand}() {
|
|
60
|
+
local -a commands
|
|
61
|
+
commands=(
|
|
62
|
+
${commands.map((c) => `'${c.name}:${(c.description ?? "").replace(/'/g, "'\\''")}'`).join("\n ")}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
_arguments \\
|
|
66
|
+
'1:command:->command' \\
|
|
67
|
+
'*::arg:->args'
|
|
68
|
+
|
|
69
|
+
case "$state" in
|
|
70
|
+
command)
|
|
71
|
+
_describe -t commands 'commands' commands
|
|
72
|
+
;;
|
|
73
|
+
args)
|
|
74
|
+
case "\${words[1]}" in
|
|
75
|
+
${commands.map((c) => `${c.name}) _${brand}_${c.name} ;;`).join("\n ")}
|
|
76
|
+
esac
|
|
77
|
+
;;
|
|
78
|
+
esac
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
${functionBlocks.join("\n\n")}
|
|
82
|
+
|
|
83
|
+
_${brand} "$@"
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=zsh.js.map
|
package/dist/zsh.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zsh.js","sourceRoot":"","sources":["../src/zsh.ts"],"names":[],"mappings":"AAEA,SAAS,0BAA0B,CAClC,KAAa,EACb,GAAsB,EACtB,MAAc;IAEd,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;IAEpF,MAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,8BAA8B;IAC9B,IAAI,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnD,MAAM,WA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;IACpE,CAAC;IAED,OAAO,YAAY,KAAK;wBACD,KAAK;;;GAG1B,KAAK;;;UAGE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;;;;;;;;;;;;;kBAa7F,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC;;;;;;EAMnG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;;GAE1B,KAAK;CACP,CAAC;AACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seedcli/completions",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shell completion generation for bash, zsh, and fish",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Rully Ardiansyah <rully@dreamshive.io>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/SeedCLI/seed",
|
|
11
|
+
"directory": "packages/completions"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://seedcli.dev",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"cli",
|
|
16
|
+
"completions",
|
|
17
|
+
"bash",
|
|
18
|
+
"zsh",
|
|
19
|
+
"fish",
|
|
20
|
+
"shell"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"bun": ">=1.3.0"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
]
|
|
40
|
+
}
|