yuangs 1.0.0 → 1.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.
- package/README.md +11 -18
- package/cli.js +26 -0
- package/index.js +24 -20
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
# yuangs
|
|
1
|
+
# yuangs CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
苑广山的个人命令行工具。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
|
+
全局安装以在终端任何位置使用:
|
|
8
|
+
|
|
7
9
|
```bash
|
|
8
|
-
npm install yuangs
|
|
10
|
+
npm install -g yuangs
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
const myPkg = require("yuangs");
|
|
15
|
-
|
|
16
|
-
// 1. 打印欢迎语
|
|
17
|
-
myPkg.sayHello("YGS");
|
|
18
|
-
// 输出: Hello, YGS! 恭喜你成功使用了 yuangs
|
|
13
|
+
## 使用命令
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
```bash
|
|
16
|
+
yuangs shici # 打开古诗词
|
|
17
|
+
yuangs dict # 打开词典
|
|
18
|
+
yuangs pong # 打开游戏
|
|
19
|
+
yuangs list # 列出所有链接
|
|
23
20
|
```
|
|
24
|
-
|
|
25
|
-
## 维护者
|
|
26
|
-
|
|
27
|
-
- yuanguangshan
|
package/cli.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const yuangs = require('./index.js');
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const command = args[0];
|
|
6
|
+
|
|
7
|
+
function printHelp() {
|
|
8
|
+
console.log(`
|
|
9
|
+
Usage: yuangs <command>
|
|
10
|
+
|
|
11
|
+
Commands:
|
|
12
|
+
shici 打开古诗词 PWA
|
|
13
|
+
dict 打开英语词典
|
|
14
|
+
pong 打开 Pong 游戏
|
|
15
|
+
list 列出所有应用链接
|
|
16
|
+
help 显示帮助信息
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
switch (command) {
|
|
21
|
+
case 'shici': yuangs.openShici(); break;
|
|
22
|
+
case 'dict': yuangs.openDict(); break;
|
|
23
|
+
case 'pong': yuangs.openPong(); break;
|
|
24
|
+
case 'list': yuangs.listApps(); break;
|
|
25
|
+
default: printHelp(); break;
|
|
26
|
+
}
|
package/index.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
console.log(message);
|
|
9
|
-
return message;
|
|
10
|
-
}
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
|
|
3
|
+
const APPS = {
|
|
4
|
+
shici: 'https://wealth.want.biz/shici/index.html',
|
|
5
|
+
dict: 'https://wealth.want.biz/pages/dict.html',
|
|
6
|
+
pong: 'https://wealth.want.biz/pages/pong.html'
|
|
7
|
+
};
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
function openUrl(url) {
|
|
10
|
+
let command;
|
|
11
|
+
switch (process.platform) {
|
|
12
|
+
case 'darwin': command = `open "${url}"`; break;
|
|
13
|
+
case 'win32': command = `start "${url}"`; break;
|
|
14
|
+
default: command = `xdg-open "${url}"`; break;
|
|
15
|
+
}
|
|
16
|
+
console.log(`正在打开: ${url} ...`);
|
|
17
|
+
exec(command);
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
module.exports = {
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
urls: APPS,
|
|
22
|
+
openShici: () => openUrl(APPS.shici),
|
|
23
|
+
openDict: () => openUrl(APPS.dict),
|
|
24
|
+
openPong: () => openUrl(APPS.pong),
|
|
25
|
+
listApps: () => {
|
|
26
|
+
console.log('--- YGS Apps ---');
|
|
27
|
+
Object.entries(APPS).forEach(([key, url]) => console.log(`${key}: ${url}`));
|
|
28
|
+
}
|
|
25
29
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuangs",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "苑广山的个人应用集合 CLI",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"yuangs": "./cli.js"
|
|
8
|
+
},
|
|
6
9
|
"scripts": {
|
|
7
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
11
|
},
|
|
9
12
|
"keywords": [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
+
"yuangs",
|
|
14
|
+
"cli",
|
|
15
|
+
"tools"
|
|
13
16
|
],
|
|
14
17
|
"author": "yuanguangshan",
|
|
15
18
|
"license": "ISC",
|