@zeng_x_pang/cli 1.0.0

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import chalk from "chalk";
4
+ import { add, minus } from "@zeng_x_pang/core";
5
+ const program = new Command();
6
+ program.name("num-cli").description("计算数字加减").version("0.0.1");
7
+ program
8
+ .command("add")
9
+ .description("加法")
10
+ .argument("a", "第一个数字")
11
+ .argument("b", "第二个数字")
12
+ .action((a, b) => {
13
+ console.log(chalk.green(add(+a, +b)));
14
+ });
15
+ program
16
+ .command("minus")
17
+ .description("减法")
18
+ .argument("a", "第一个数字")
19
+ .argument("b", "第二个数字")
20
+ .action((a, b) => {
21
+ console.log(chalk.cyan(minus(+a, +b)));
22
+ });
23
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@zeng_x_pang/cli",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "bin": {
12
+ "calc": "dist/index.js"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "keywords": [],
18
+ "author": "",
19
+ "license": "ISC",
20
+ "dependencies": {
21
+ "@zeng_x_pang/core": "1.0.0",
22
+ "chalk": "^5.6.2",
23
+ "commander": "^14.0.3"
24
+ }
25
+ }
package/src/index.ts ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import chalk from "chalk";
4
+ import { add, minus } from "@zeng_x_pang/core";
5
+
6
+ const program = new Command();
7
+
8
+ program.name("num-cli").description("计算数字加减").version("0.0.1");
9
+
10
+ program
11
+ .command("add")
12
+ .description("加法")
13
+ .argument("a", "第一个数字")
14
+ .argument("b", "第二个数字")
15
+ .action((a: string, b: string) => {
16
+ console.log(chalk.green(add(+a, +b)));
17
+ });
18
+
19
+ program
20
+ .command("minus")
21
+ .description("减法")
22
+ .argument("a", "第一个数字")
23
+ .argument("b", "第二个数字")
24
+ .action((a: string, b: string) => {
25
+ console.log(chalk.cyan(minus(+a, +b)));
26
+ });
27
+
28
+ program.parse();
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "outDir": "dist",
5
+
6
+ "types": ["node"],
7
+ "target": "es2016",
8
+ "module": "NodeNext",
9
+ "moduleResolution": "NodeNext",
10
+ "declaration": true,
11
+ "esModuleInterop": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "strict": true,
14
+ "skipLibCheck": true
15
+ },
16
+ "include": ["src/**/*"]
17
+ }