@moostjs/event-cli 0.2.12 → 0.2.14
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/dist/index.cjs +11 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +12 -15
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -99,16 +99,8 @@ class MoostCli {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/* istanbul ignore file */
|
|
105
|
-
function logError(error) {
|
|
106
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function panic(error) {
|
|
110
|
-
logError(error);
|
|
111
|
-
return new Error(error);
|
|
102
|
+
function getCliMate() {
|
|
103
|
+
return moost.getMoostMate();
|
|
112
104
|
}
|
|
113
105
|
|
|
114
106
|
/**
|
|
@@ -128,8 +120,13 @@ function Flag(name) {
|
|
|
128
120
|
function Flags() {
|
|
129
121
|
return moost.Resolve(() => eventCli.useFlags(), 'flags');
|
|
130
122
|
}
|
|
123
|
+
function formatParams(keys) {
|
|
124
|
+
const names = [keys].flat();
|
|
125
|
+
return names.map(n => n.length === 1 ? '-' + n : '--' + n);
|
|
126
|
+
}
|
|
131
127
|
function CliParam(keys, descr) {
|
|
132
|
-
|
|
128
|
+
const mate = getCliMate();
|
|
129
|
+
return mate.apply(mate.decorate('cliParams', { keys, descr }, true), moost.Resolve(() => {
|
|
133
130
|
const flags = eventCli.useFlags();
|
|
134
131
|
const names = [keys].flat();
|
|
135
132
|
const vals = [];
|
|
@@ -139,17 +136,17 @@ function CliParam(keys, descr) {
|
|
|
139
136
|
}
|
|
140
137
|
}
|
|
141
138
|
if (vals.length > 1) {
|
|
142
|
-
throw
|
|
139
|
+
throw new Error(`Options ${formatParams(names).join(' and ')} are synonyms. Please use only one of them.`);
|
|
143
140
|
}
|
|
144
141
|
if (vals.length === 0) {
|
|
145
142
|
return false;
|
|
146
143
|
}
|
|
147
144
|
return vals[0];
|
|
148
|
-
});
|
|
145
|
+
}, formatParams(keys).join(', ')));
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
function Cli(path) {
|
|
152
|
-
return
|
|
149
|
+
return getCliMate().decorate('handlers', { path, type: 'CLI' }, true);
|
|
153
150
|
}
|
|
154
151
|
|
|
155
152
|
exports.Cli = Cli;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { WooksCli } from '@wooksjs/event-cli';
|
|
|
5
5
|
|
|
6
6
|
export declare function Cli(path?: string): MethodDecorator;
|
|
7
7
|
|
|
8
|
-
export declare function CliParam(keys: string | [string, string], descr?: string): ParameterDecorator & PropertyDecorator;
|
|
8
|
+
export declare function CliParam(keys: string | [string, string], descr?: string): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Get Cli Flag
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WooksCli, createCliApp, useCliContext, useFlags } from '@wooksjs/event-cli';
|
|
2
2
|
import { useEventId } from '@wooksjs/event-core';
|
|
3
|
-
import {
|
|
3
|
+
import { getMoostMate, Resolve } from 'moost';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -97,16 +97,8 @@ class MoostCli {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/* istanbul ignore file */
|
|
103
|
-
function logError(error) {
|
|
104
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function panic(error) {
|
|
108
|
-
logError(error);
|
|
109
|
-
return new Error(error);
|
|
100
|
+
function getCliMate() {
|
|
101
|
+
return getMoostMate();
|
|
110
102
|
}
|
|
111
103
|
|
|
112
104
|
/**
|
|
@@ -126,8 +118,13 @@ function Flag(name) {
|
|
|
126
118
|
function Flags() {
|
|
127
119
|
return Resolve(() => useFlags(), 'flags');
|
|
128
120
|
}
|
|
121
|
+
function formatParams(keys) {
|
|
122
|
+
const names = [keys].flat();
|
|
123
|
+
return names.map(n => n.length === 1 ? '-' + n : '--' + n);
|
|
124
|
+
}
|
|
129
125
|
function CliParam(keys, descr) {
|
|
130
|
-
|
|
126
|
+
const mate = getCliMate();
|
|
127
|
+
return mate.apply(mate.decorate('cliParams', { keys, descr }, true), Resolve(() => {
|
|
131
128
|
const flags = useFlags();
|
|
132
129
|
const names = [keys].flat();
|
|
133
130
|
const vals = [];
|
|
@@ -137,17 +134,17 @@ function CliParam(keys, descr) {
|
|
|
137
134
|
}
|
|
138
135
|
}
|
|
139
136
|
if (vals.length > 1) {
|
|
140
|
-
throw
|
|
137
|
+
throw new Error(`Options ${formatParams(names).join(' and ')} are synonyms. Please use only one of them.`);
|
|
141
138
|
}
|
|
142
139
|
if (vals.length === 0) {
|
|
143
140
|
return false;
|
|
144
141
|
}
|
|
145
142
|
return vals[0];
|
|
146
|
-
});
|
|
143
|
+
}, formatParams(keys).join(', ')));
|
|
147
144
|
}
|
|
148
145
|
|
|
149
146
|
function Cli(path) {
|
|
150
|
-
return
|
|
147
|
+
return getCliMate().decorate('handlers', { path, type: 'CLI' }, true);
|
|
151
148
|
}
|
|
152
149
|
|
|
153
150
|
export { Cli, CliParam, Flag, Flags, MoostCli };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "@moostjs/event-cli",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-cli#readme",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"moost": "0.2.
|
|
32
|
-
"wooks": "^0.2.
|
|
33
|
-
"@wooksjs/event-core": "^0.2.
|
|
31
|
+
"moost": "0.2.14",
|
|
32
|
+
"wooks": "^0.2.7",
|
|
33
|
+
"@wooksjs/event-core": "^0.2.7"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@wooksjs/event-cli": "^0.2.
|
|
36
|
+
"@wooksjs/event-cli": "^0.2.7"
|
|
37
37
|
}
|
|
38
38
|
}
|