@kokiito0926/pseudoalias 0.0.2 → 0.0.4

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.
Files changed (2) hide show
  1. package/index.js +18 -15
  2. 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
@@ -16,14 +22,15 @@
16
22
  // そのような処理を実装するのであれば、os.homedir関数を用いればいいような気がする。
17
23
  // >> 2026/01/27 18:33.
18
24
 
19
- // >> $ node ./index.js --config example.js
20
- // >> $ node ./index.js --config example.js greetings
21
- // >> $ node ./index.js --config example.js addition 1 2
25
+ // >> $ ./index.js --config example.js
26
+ // >> $ ./index.js --config example.js greetings
27
+ // >> $ ./index.js --config example.js addition 1 2
22
28
 
23
29
  import { minimist, fs, path, argv } from "zx";
24
30
  import { pathToFileURL } from "node:url";
25
31
 
26
32
  const commands = argv._;
33
+ // console.log(commands);
27
34
 
28
35
  const args = minimist(process.argv.slice(2));
29
36
  const config = args.config;
@@ -32,15 +39,11 @@ const completion = args.completion;
32
39
  // console.log(args);
33
40
  // process.exit(0);
34
41
 
35
- // console.log("aaaa\nbbbb\ncccc");
36
- // process.exit(0);
37
-
38
42
  const targetFile = config;
39
43
  if (!targetFile) {
40
44
  process.exit(0);
41
45
  }
42
46
 
43
- // const targetPath = targetFile;
44
47
  const targetPath = path.resolve(targetFile);
45
48
  if (!targetPath) {
46
49
  process.exit(0);
@@ -55,17 +58,17 @@ try {
55
58
  // console.log(restArgs);
56
59
  // process.exit(0);
57
60
 
58
- const prevWord = process.argv[process?.argv?.length - 1];
59
- const currentWord = process.argv[process?.argv?.length - 2];
60
-
61
61
  if (completion) {
62
- // fs.writeFileSync("./temp.txt", prevWord, "utf-8");
63
- // fs.writeFileSync("./temp.txt", currentWord, "utf-8");
64
- // process.exit(0);
62
+ const args2 = process.argv;
63
+ const prevWord = args2[args2.length - 1];
64
+ const currentWord = args2[args2.length - 2];
65
65
 
66
66
  if (prevWord === "pseudoalias") {
67
- const availableFunctions = Object.keys(aliasModule).filter((k) => k !== "default");
68
- console.log(availableFunctions.join("\n"));
67
+ const candidates = Object.keys(aliasModule).filter((k) => k !== "default");
68
+ const filtered = candidates.filter((c) => c.startsWith(currentWord));
69
+ if (filtered.length > 0) {
70
+ console.log(filtered.join("\n"));
71
+ }
69
72
  process.exit(0);
70
73
  }
71
74
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokiito0926/pseudoalias",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "private": false,
5
5
  "description": "スードーエイリアス(pseudoalias)を用いれば、擬似的なエイリアスを作成することができます。",
6
6
  "keywords": [