@doracli/commander 0.0.3 → 0.0.5

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 CHANGED
@@ -1,7 +1,6 @@
1
1
  # `cli`
2
2
 
3
3
  > @doracli/cli
4
- 构建功能集合
4
+ > 构建功能集合
5
5
 
6
6
  ## Usage
7
-
package/lib/cjs/index.js CHANGED
@@ -1 +1,46 @@
1
- "use strict";var n=require("commander"),o=function(o){return new n.Command(o)},e=function(n){return function(e){var t=n.command,r=n.description,a=n.action,i=n.help,c=n.options,m=o(t);m.description(r),(c||[]).forEach(function(n){var o=n.name,e=n.simpleName,t=n.description,r=n.type,a=n.defaultValue;m.option("-".concat(e," --").concat(o," ").concat(r),t,a)}),m.action(a),i&&i.onHelp&&m.on("--help",i.onHelp),e.addCommand(m)}};exports.createChildCommand=o,exports.createProgram=function(){return n.program},exports.dealChildOption=e,exports.dealOptions=function(n){return function(o){var t=n.name,r=n.usage,a=n.version,i=n.childCommands;o.name(t),r&&o.usage(r),a&&o.version(a),(i||[]).forEach(function(n){e(n)(o)})}};
1
+ 'use strict';
2
+ var n = require('commander'),
3
+ o = function (o) {
4
+ return new n.Command(o);
5
+ },
6
+ e = function (n) {
7
+ return function (e) {
8
+ var t = n.command,
9
+ r = n.description,
10
+ a = n.action,
11
+ i = n.help,
12
+ c = n.options,
13
+ m = o(t);
14
+ (m.description(r),
15
+ (c || []).forEach(function (n) {
16
+ var o = n.name,
17
+ e = n.simpleName,
18
+ t = n.description,
19
+ r = n.type,
20
+ a = n.defaultValue;
21
+ m.option('-'.concat(e, ' --').concat(o, ' ').concat(r), t, a);
22
+ }),
23
+ m.action(a),
24
+ i && i.onHelp && m.on('--help', i.onHelp),
25
+ e.addCommand(m));
26
+ };
27
+ };
28
+ ((exports.createChildCommand = o),
29
+ (exports.createProgram = function () {
30
+ return n.program;
31
+ }),
32
+ (exports.dealChildOption = e),
33
+ (exports.dealOptions = function (n) {
34
+ return function (o) {
35
+ var t = n.name,
36
+ r = n.usage,
37
+ a = n.version,
38
+ i = n.childCommands;
39
+ (o.name(t),
40
+ r && o.usage(r),
41
+ a && o.version(a),
42
+ (i || []).forEach(function (n) {
43
+ e(n)(o);
44
+ }));
45
+ };
46
+ }));
package/lib/esm/index.js CHANGED
@@ -1 +1,49 @@
1
- import{Command as n,program as o}from"commander";var e=function(o){return new n(o)},t=function(){return o},a=function(n){return function(o){var e=n.name,t=n.usage,a=n.version,i=n.childCommands;o.name(e),t&&o.usage(t),a&&o.version(a),(i||[]).forEach(function(n){c(n)(o)})}},c=function(n){return function(o){var t=n.command,a=n.description,c=n.action,i=n.help,r=n.options,u=e(t);u.description(a),(r||[]).forEach(function(n){var o=n.name,e=n.simpleName,t=n.description,a=n.type,c=n.defaultValue;u.option("-".concat(e," --").concat(o," ").concat(a),t,c)}),u.action(c),i&&i.onHelp&&u.on("--help",i.onHelp),o.addCommand(u)}};export{e as createChildCommand,t as createProgram,c as dealChildOption,a as dealOptions};
1
+ import { Command as n, program as o } from 'commander';
2
+ var e = function (o) {
3
+ return new n(o);
4
+ },
5
+ t = function () {
6
+ return o;
7
+ },
8
+ a = function (n) {
9
+ return function (o) {
10
+ var e = n.name,
11
+ t = n.usage,
12
+ a = n.version,
13
+ i = n.childCommands;
14
+ (o.name(e),
15
+ t && o.usage(t),
16
+ a && o.version(a),
17
+ (i || []).forEach(function (n) {
18
+ c(n)(o);
19
+ }));
20
+ };
21
+ },
22
+ c = function (n) {
23
+ return function (o) {
24
+ var t = n.command,
25
+ a = n.description,
26
+ c = n.action,
27
+ i = n.help,
28
+ r = n.options,
29
+ u = e(t);
30
+ (u.description(a),
31
+ (r || []).forEach(function (n) {
32
+ var o = n.name,
33
+ e = n.simpleName,
34
+ t = n.description,
35
+ a = n.type,
36
+ c = n.defaultValue;
37
+ u.option('-'.concat(e, ' --').concat(o, ' ').concat(a), t, c);
38
+ }),
39
+ u.action(c),
40
+ i && i.onHelp && u.on('--help', i.onHelp),
41
+ o.addCommand(u));
42
+ };
43
+ };
44
+ export {
45
+ e as createChildCommand,
46
+ t as createProgram,
47
+ c as dealChildOption,
48
+ a as dealOptions,
49
+ };
@@ -1,6 +1,6 @@
1
- import * as commander from 'commander';
2
- import { Command } from 'commander';
3
- import { TPlainFunction } from '@cclr/lang';
1
+ import type * as commander from 'commander';
2
+ import type { Command } from 'commander';
3
+ import type { TPlainFunction } from '@cclr/lang';
4
4
 
5
5
  declare const createChildCommand: (childComman: string) => Command;
6
6
 
@@ -9,45 +9,45 @@ declare const createProgram: () => commander.Command;
9
9
 
10
10
  type TCommandOptionList = TCommandOption[];
11
11
  type TCommandOption = {
12
- name: string;
13
- usage?: string;
14
- version?: string;
15
- childCommands?: TChildCommandOption[];
12
+ name: string;
13
+ usage?: string;
14
+ version?: string;
15
+ childCommands?: TChildCommandOption[];
16
16
  };
17
17
  /**
18
18
  * 实际会执行的命令
19
19
  * @description 带详细配置参数
20
20
  */
21
21
  type TChildCommandOption = {
22
- command: string;
23
- description: string;
24
- options?: {
25
- /**
26
- * 主要命令
27
- * @description 会自动拼接成 --version
28
- * @example version
29
- */
30
- name: string;
31
- /**
32
- * 简写命令
33
- * @description 会自动拼接成 -V
34
- * @example V
35
- */
36
- simpleName: string;
37
- /**
38
- * 参数类型
39
- * @example undefined -> boolean
40
- * @example <number> -> 用户输入的值
41
- * @example [file] -> 可选参数
42
- */
43
- type?: string;
44
- description?: string;
45
- defaultValue?: string | boolean | number;
46
- }[];
47
- action: TPlainFunction;
48
- help?: {
49
- onHelp?: () => void;
50
- };
22
+ command: string;
23
+ description: string;
24
+ options?: {
25
+ /**
26
+ * 主要命令
27
+ * @description 会自动拼接成 --version
28
+ * @example version
29
+ */
30
+ name: string;
31
+ /**
32
+ * 简写命令
33
+ * @description 会自动拼接成 -V
34
+ * @example V
35
+ */
36
+ simpleName: string;
37
+ /**
38
+ * 参数类型
39
+ * @example undefined -> boolean
40
+ * @example <number> -> 用户输入的值
41
+ * @example [file] -> 可选参数
42
+ */
43
+ type?: string;
44
+ description?: string;
45
+ defaultValue?: string | boolean | number;
46
+ }[];
47
+ action: TPlainFunction;
48
+ help?: {
49
+ onHelp?: () => void;
50
+ };
51
51
  };
52
52
 
53
53
  /**
@@ -61,7 +61,9 @@ declare const dealOptions: (options: TCommandOption) => (c: Command) => void;
61
61
  * @param option 子命令配置
62
62
  * @returns
63
63
  */
64
- declare const dealChildOption: (option: TChildCommandOption) => (c: Command) => void;
64
+ declare const dealChildOption: (
65
+ option: TChildCommandOption
66
+ ) => (c: Command) => void;
65
67
 
66
68
  export { createChildCommand, createProgram, dealChildOption, dealOptions };
67
69
  export type { TChildCommandOption, TCommandOption, TCommandOptionList };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doracli/commander",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "command line parser",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
@@ -25,13 +25,13 @@
25
25
  "scripts": {
26
26
  "test": "vitest",
27
27
  "g:test": "vitest run",
28
- "build": "drn build"
28
+ "build": "drr build"
29
29
  },
30
30
  "dependencies": {
31
- "@cclr/lang": "^0.1.28",
32
- "@cclr/utils": "^0.1.28",
33
- "@doracli/type": "^0.0.3",
34
- "commander": "^14.0.1"
31
+ "@cclr/lang": "^0.1.49",
32
+ "@cclr/utils": "^0.1.49",
33
+ "@doracli/type": "^0.0.5",
34
+ "commander": "^14.0.2"
35
35
  },
36
- "gitHead": "c89b02be8c385738ad80749447133d30e00b1f75"
36
+ "gitHead": "ac4c6829b2cec621ecf66b6324843773e8b5141f"
37
37
  }