@kokiito0926/pseudoalias 0.0.5 → 0.0.7

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 (3) hide show
  1. package/README.md +43 -7
  2. package/index.js +7 -3
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- ## スードーエイリアス(pseudoalias
1
+ ## pseudoalias
2
2
 
3
- スードーエイリアス(pseudoalias)を用いれば、擬似的なエイリアスを作成することができます。
4
- .bashrcなどにエイリアスを書くよりも、JavaScriptのファイルにエイリアスを書けたほうが便利かと思いました。
3
+ pseudoaliasは、擬似的なエイリアスを作成することができるコマンドラインのツールです。
4
+ .bashrcなどにエイリアスを書くよりも、JavaScriptでエイリアスを書けるようになるので、書きやすいような気がします。
5
5
 
6
6
  ## インストール
7
7
 
@@ -9,26 +9,62 @@
9
9
  $ npm install --global @kokiito0926/pseudoalias
10
10
  ```
11
11
 
12
- ## 実行方法
12
+ ## 使用方法
13
+
14
+ 設定のファイルにエイリアスを記述します。
15
+
16
+ ```javascript
17
+ export const greetings = async () => {
18
+ console.log("Hello, world!");
19
+ };
20
+
21
+ export const addition = async (one, two) => {
22
+ console.log(Number(one) + Number(two));
23
+ };
24
+
25
+ export const subtraction = async (one, two) => {
26
+ console.log(Number(one) - Number(two));
27
+ };
28
+
29
+ export const multiplication = async (one, two) => {
30
+ console.log(Number(one) * Number(two));
31
+ };
32
+
33
+ export const division = async (one, two) => {
34
+ console.log(Number(one) / Number(two));
35
+ };
36
+ ```
37
+
38
+ --configのオプションに設定のファイルを指定します。
39
+ そうしたら、定義されているエイリアスを実行することができます。
13
40
 
14
41
  ```bash
15
- $ pseudoalias --config ./example.js
16
42
  $ pseudoalias --config ./example.js greetings
17
43
  $ pseudoalias --config ./example.js addition 1 2
18
44
  $ pseudoalias --config ./example.js subtraction 2 1
19
45
  ```
20
46
 
47
+ エイリアスを書かずに実行した場合、エイリアスの一覧が表示されます。
48
+
49
+ ```bash
50
+ $ pseudoalias --config ./example.js
51
+ ```
52
+
53
+ --registerのオプションを用いると、ホームディレクトリに設定のファイルが保存されます。
54
+ それ以降は、--configのオプションを用いなくても、定義されているエイリアスを実行することができます。
55
+
21
56
  ```bash
22
57
  $ pseudoalias --config ./example.js --register
23
- $ pseudoalias --unregister
24
58
 
25
59
  $ pseudoalias greetings
26
60
  $ pseudoalias addition 1 2
27
61
  $ pseudoalias subtraction 2 1
28
62
  ```
29
63
 
64
+ --unregisterのオプションを用いると、ホームディレクトリから設定のファイルを削除します。
65
+
30
66
  ```bash
31
- $ complete -C "pseudoalias --config ./example.js --completion" -o default pseudoalias
67
+ $ pseudoalias --unregister
32
68
  ```
33
69
 
34
70
  ## ライセンス
package/index.js CHANGED
@@ -31,8 +31,7 @@
31
31
  // >> $ ./index.js addition 1 2
32
32
  // >> $ ./index.js --unregister
33
33
 
34
- import os from "node:os";
35
- import { minimist, fs, path, argv } from "zx";
34
+ import { os, minimist, fs, path, argv } from "zx";
36
35
  import { pathToFileURL } from "node:url";
37
36
 
38
37
  const CONFIG_DIR = path.join(os.homedir(), ".pseudoalias");
@@ -43,11 +42,14 @@ const commands = argv._;
43
42
 
44
43
  const args = minimist(process.argv.slice(2));
45
44
  const config = args.config;
46
- const completion = args.completion;
47
45
  // console.log(argv);
48
46
  // console.log(args);
49
47
  // process.exit(0);
50
48
 
49
+ /*
50
+ const completion = args.completion;
51
+ */
52
+
51
53
  if (args.register) {
52
54
  if (args.config) {
53
55
  const absConfigPath = path.resolve(args.config);
@@ -101,6 +103,7 @@ try {
101
103
  // console.log(restArgs);
102
104
  // process.exit(0);
103
105
 
106
+ /*
104
107
  if (completion) {
105
108
  const args2 = process.argv;
106
109
  const prevWord = args2[args2.length - 1];
@@ -116,6 +119,7 @@ try {
116
119
  }
117
120
  process.exit(0);
118
121
  }
122
+ */
119
123
 
120
124
  if (!subCommand) {
121
125
  const availableFunctions = Object.keys(aliasModule).filter((k) => k !== "default");
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kokiito0926/pseudoalias",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
- "description": "スードーエイリアス(pseudoalias)を用いれば、擬似的なエイリアスを作成することができます。",
5
+ "description": "擬似的なエイリアスを作成することができるコマンドラインのツールです。",
6
6
  "keywords": [
7
7
  "cli",
8
8
  "bash",