@breadc/core 1.0.0-beta.4 → 1.0.0-beta.6
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.d.mts +1 -1
- package/dist/index.mjs +8 -4
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -614,7 +614,7 @@ type Command<Spec extends string = string, Init extends CommandInit<Spec> = Comm
|
|
|
614
614
|
*/
|
|
615
615
|
action<R extends unknown>(fn: (...args: [...Arguments, Prettify<Options & {
|
|
616
616
|
'--': string[];
|
|
617
|
-
}>]) => Promise<R> | R): Command<Spec, Init, Data, Options, Arguments, R>;
|
|
617
|
+
}>, Context<Data>]) => Promise<R> | R): Command<Spec, Init, Data, Options, Arguments, R>;
|
|
618
618
|
/**
|
|
619
619
|
* Run command directly
|
|
620
620
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -783,6 +783,8 @@ function buildGroup(group) {
|
|
|
783
783
|
//#endregion
|
|
784
784
|
//#region src/breadc/builtin/i18n.ts
|
|
785
785
|
const en = {
|
|
786
|
+
OPTIONS: "OPTIONS",
|
|
787
|
+
COMMAND: "COMMAND",
|
|
786
788
|
"Usage:": "Usage:",
|
|
787
789
|
"Commands:": "Commands:",
|
|
788
790
|
"Options:": "Options:",
|
|
@@ -790,7 +792,9 @@ const en = {
|
|
|
790
792
|
"Print version": "Print version"
|
|
791
793
|
};
|
|
792
794
|
const zh = {
|
|
793
|
-
|
|
795
|
+
OPTIONS: "选项",
|
|
796
|
+
COMMAND: "子命令",
|
|
797
|
+
"Usage:": "用法:",
|
|
794
798
|
"Commands:": "命令:",
|
|
795
799
|
"Options:": "选项:",
|
|
796
800
|
"Print help": "显示帮助信息",
|
|
@@ -928,7 +932,7 @@ function buildHelpOption(context) {
|
|
|
928
932
|
function printHelp(context) {
|
|
929
933
|
const { breadc, pieces } = context;
|
|
930
934
|
const { allCommands, commands, options } = collect(context, pieces);
|
|
931
|
-
const usage = allCommands.length === 0 ? "
|
|
935
|
+
const usage = allCommands.length === 0 ? `[${i18n(context, "OPTIONS")}]` : allCommands.length === 1 ? `[${i18n(context, "OPTIONS")}] ${formatCommand(allCommands[0])}` : allCommands.some((command) => command._default) ? `[${i18n(context, "OPTIONS")}] [${i18n(context, "COMMAND")}]` : `[${i18n(context, "OPTIONS")}] <${i18n(context, "COMMAND")}>`;
|
|
932
936
|
const text = expandMessage([
|
|
933
937
|
`${breadc.name}/${breadc._init.version ?? "unknown"}`,
|
|
934
938
|
() => {
|
|
@@ -1162,7 +1166,7 @@ async function run(app, argv) {
|
|
|
1162
1166
|
options["--"] = context.remaining;
|
|
1163
1167
|
if (context.command._actionFn) {
|
|
1164
1168
|
const actionFn = context.command._actionFn;
|
|
1165
|
-
if (actionMiddlewares.length === 0) return await actionFn(...args, options);
|
|
1169
|
+
if (actionMiddlewares.length === 0) return await actionFn(...args, options, context);
|
|
1166
1170
|
else {
|
|
1167
1171
|
const invoked = [];
|
|
1168
1172
|
const makeNextFn = (index) => {
|
|
@@ -1172,7 +1176,7 @@ async function run(app, argv) {
|
|
|
1172
1176
|
...nextContext?.data
|
|
1173
1177
|
};
|
|
1174
1178
|
invoked[index] = true;
|
|
1175
|
-
if (index === actionMiddlewares.length) context.output = await actionFn(...args, options);
|
|
1179
|
+
if (index === actionMiddlewares.length) context.output = await actionFn(...args, options, context);
|
|
1176
1180
|
else {
|
|
1177
1181
|
const next = makeNextFn(index + 1);
|
|
1178
1182
|
await actionMiddlewares[index](context, next);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadc/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "Yet another Command Line Application Framework with fully strong TypeScript support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"breadc",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@breadc/color": "1.0.0-beta.
|
|
36
|
+
"@breadc/color": "1.0.0-beta.6"
|
|
37
37
|
},
|
|
38
38
|
"size-limit": [
|
|
39
39
|
{
|