@kokiito0926/pseudoalias 0.0.2 → 0.0.3
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/index.js +27 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// いちおう、Bashで入力補完が効くようになった。
|
|
4
|
+
// タブを1回だけ押したときに入力補完が決まるようになった。
|
|
5
|
+
// それから、ファイルのパスの入力補完も効くようになった。
|
|
6
|
+
// >> $ complete -C "pseudoalias --config ./example.js --completion" -o default pseudoalias
|
|
7
|
+
// >> 2026/01/27 21:36.
|
|
8
|
+
|
|
3
9
|
// いちおう、入力補完のコマンドを書いておいたほうがいい。
|
|
4
10
|
// -oのオプションにdefaultを指定していても、ファイルのパスの入力補完が効かない。
|
|
5
11
|
// >> $ complete -p
|
|
@@ -55,19 +61,36 @@ try {
|
|
|
55
61
|
// console.log(restArgs);
|
|
56
62
|
// process.exit(0);
|
|
57
63
|
|
|
58
|
-
const prevWord = process.argv[process?.argv?.length - 1];
|
|
59
|
-
const currentWord = process.argv[process?.argv?.length - 2];
|
|
64
|
+
// const prevWord = process.argv[process?.argv?.length - 1];
|
|
65
|
+
// const currentWord = process.argv[process?.argv?.length - 2];
|
|
60
66
|
|
|
61
67
|
if (completion) {
|
|
62
68
|
// fs.writeFileSync("./temp.txt", prevWord, "utf-8");
|
|
63
69
|
// fs.writeFileSync("./temp.txt", currentWord, "utf-8");
|
|
64
70
|
// process.exit(0);
|
|
65
71
|
|
|
72
|
+
const args2 = process.argv;
|
|
73
|
+
const prevWord = args2[args2.length - 1];
|
|
74
|
+
const currentWord = args2[args2.length - 2];
|
|
75
|
+
|
|
66
76
|
if (prevWord === "pseudoalias") {
|
|
67
|
-
const
|
|
68
|
-
|
|
77
|
+
const candidates = Object.keys(aliasModule).filter((k) => k !== "default");
|
|
78
|
+
// const candidates = ["addition", "division", "greetings", "multiplication", "subtraction"];
|
|
79
|
+
|
|
80
|
+
const filtered = candidates.filter((c) => c.startsWith(currentWord));
|
|
81
|
+
|
|
82
|
+
if (filtered.length > 0) {
|
|
83
|
+
console.log(filtered.join("\n"));
|
|
84
|
+
}
|
|
69
85
|
process.exit(0);
|
|
70
86
|
}
|
|
87
|
+
|
|
88
|
+
// if (prevWord === "pseudoalias") {
|
|
89
|
+
// const availableFunctions = Object.keys(aliasModule).filter((k) => k !== "default");
|
|
90
|
+
// console.log(availableFunctions.join("\n"));
|
|
91
|
+
// process.exit(0);
|
|
92
|
+
// }
|
|
93
|
+
|
|
71
94
|
process.exit(0);
|
|
72
95
|
}
|
|
73
96
|
|