@kokiito0926/pseudoalias 0.0.1 → 0.0.2

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 +32 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,5 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // いちおう、入力補完のコマンドを書いておいたほうがいい。
4
+ // -oのオプションにdefaultを指定していても、ファイルのパスの入力補完が効かない。
5
+ // >> $ complete -p
6
+ // >> $ complete -r pseudoalias
7
+ // >> $ complete -C "./index.js --config ./example.js --completion" -o default pseudoalias
8
+ // >> 2026/01/27 20:53.
9
+
10
+ // 入力補完の単語を表示する機能を実装した。
11
+ // >> $ ./index.js --config ./example.js --completion
12
+ // >> 2026/01/27 20:18.
13
+
3
14
  // ホームディレクトリに設定のファイルを保存できるようにする。
4
15
  // そのようにすれば、コマンドをより短くすることができると思う。
5
16
  // そのような処理を実装するのであれば、os.homedir関数を用いればいいような気がする。
@@ -9,17 +20,21 @@
9
20
  // >> $ node ./index.js --config example.js greetings
10
21
  // >> $ node ./index.js --config example.js addition 1 2
11
22
 
12
- import { minimist, path, argv } from "zx";
23
+ import { minimist, fs, path, argv } from "zx";
13
24
  import { pathToFileURL } from "node:url";
14
25
 
15
26
  const commands = argv._;
16
27
 
17
28
  const args = minimist(process.argv.slice(2));
18
29
  const config = args.config;
30
+ const completion = args.completion;
19
31
  // console.log(argv);
20
32
  // console.log(args);
21
33
  // process.exit(0);
22
34
 
35
+ // console.log("aaaa\nbbbb\ncccc");
36
+ // process.exit(0);
37
+
23
38
  const targetFile = config;
24
39
  if (!targetFile) {
25
40
  process.exit(0);
@@ -40,6 +55,22 @@ try {
40
55
  // console.log(restArgs);
41
56
  // process.exit(0);
42
57
 
58
+ const prevWord = process.argv[process?.argv?.length - 1];
59
+ const currentWord = process.argv[process?.argv?.length - 2];
60
+
61
+ if (completion) {
62
+ // fs.writeFileSync("./temp.txt", prevWord, "utf-8");
63
+ // fs.writeFileSync("./temp.txt", currentWord, "utf-8");
64
+ // process.exit(0);
65
+
66
+ if (prevWord === "pseudoalias") {
67
+ const availableFunctions = Object.keys(aliasModule).filter((k) => k !== "default");
68
+ console.log(availableFunctions.join("\n"));
69
+ process.exit(0);
70
+ }
71
+ process.exit(0);
72
+ }
73
+
43
74
  if (!subCommand) {
44
75
  const availableFunctions = Object.keys(aliasModule).filter((k) => k !== "default");
45
76
  console.log("Available aliases:");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokiito0926/pseudoalias",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "description": "スードーエイリアス(pseudoalias)を用いれば、擬似的なエイリアスを作成することができます。",
6
6
  "keywords": [