yuangs 1.0.1 → 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.
Files changed (4) hide show
  1. package/README.md +11 -26
  2. package/cli.js +26 -0
  3. package/index.js +5 -32
  4. package/package.json +6 -4
package/README.md CHANGED
@@ -1,35 +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
- 包含以下个人应用的快捷访问:
14
-
15
- 1. **古诗词 PWA**: [https://wealth.want.biz/shici/index.html](https://wealth.want.biz/shici/index.html)
16
- 2. **英语词典**: [https://wealth.want.biz/pages/dict.html](https://wealth.want.biz/pages/dict.html)
17
- 3. **Pong 游戏**: [https://wealth.want.biz/pages/pong.html](https://wealth.want.biz/pages/pong.html)
18
-
19
- ## 使用方法
20
-
21
- ```javascript
22
- const yuangs = require("yuangs");
13
+ ## 使用命令
23
14
 
24
- // 1. 列出所有应用
25
- yuangs.listApps();
26
-
27
- // 2. 在浏览器中打开应用 (支持 Mac/Windows/Linux)
28
- yuangs.openShici(); // 打开古诗词
29
- yuangs.openDict(); // 打开词典
30
- yuangs.openPong(); // 打开游戏
15
+ ```bash
16
+ yuangs shici # 打开古诗词
17
+ yuangs dict # 打开词典
18
+ yuangs pong # 打开游戏
19
+ yuangs list # 列出所有链接
31
20
  ```
32
-
33
- ## 维护者
34
-
35
- - 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,5 +1,4 @@
1
1
  const { exec } = require('child_process');
2
- const os = require('os');
3
2
 
4
3
  const APPS = {
5
4
  shici: 'https://wealth.want.biz/shici/index.html',
@@ -7,50 +6,24 @@ const APPS = {
7
6
  pong: 'https://wealth.want.biz/pages/pong.html'
8
7
  };
9
8
 
10
- /**
11
- * 打开 URL 的通用函数
12
- * @param {string} url
13
- */
14
9
  function openUrl(url) {
15
10
  let command;
16
11
  switch (process.platform) {
17
- case 'darwin': // macOS
18
- command = `open "${url}"`;
19
- break;
20
- case 'win32': // Windows
21
- command = `start "${url}"`;
22
- break;
23
- default: // Linux
24
- command = `xdg-open "${url}"`;
25
- break;
12
+ case 'darwin': command = `open "${url}"`; break;
13
+ case 'win32': command = `start "${url}"`; break;
14
+ default: command = `xdg-open "${url}"`; break;
26
15
  }
27
-
28
16
  console.log(`正在打开: ${url} ...`);
29
- exec(command, (error) => {
30
- if (error) {
31
- console.error(`打开失败: ${error.message}`);
32
- }
33
- });
17
+ exec(command);
34
18
  }
35
19
 
36
20
  module.exports = {
37
- // 导出链接常量
38
21
  urls: APPS,
39
-
40
- // 打开古诗词应用
41
22
  openShici: () => openUrl(APPS.shici),
42
-
43
- // 打开英语词典
44
23
  openDict: () => openUrl(APPS.dict),
45
-
46
- // 打开 Pong 游戏
47
24
  openPong: () => openUrl(APPS.pong),
48
-
49
- // 打印所有应用列表
50
25
  listApps: () => {
51
26
  console.log('--- YGS Apps ---');
52
- console.log(`1. 古诗词 (PWA): ${APPS.shici}`);
53
- console.log(`2. 英语词典: ${APPS.dict}`);
54
- console.log(`3. Pong 游戏: ${APPS.pong}`);
27
+ Object.entries(APPS).forEach(([key, url]) => console.log(`${key}: ${url}`));
55
28
  }
56
29
  };
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "yuangs",
3
- "version": "1.0.1",
4
- "description": "苑广山的个人应用集合 (PWA, 词典, 游戏)",
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
13
  "yuangs",
11
- "pwa",
12
- "game",
14
+ "cli",
13
15
  "tools"
14
16
  ],
15
17
  "author": "yuanguangshan",