@h3ravel/musket 0.6.1 → 0.6.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.
- package/dist/index.cjs +11 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +11 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -845,11 +845,17 @@ var Musket = class Musket {
|
|
|
845
845
|
if (this.resolver) return await this.resolver(cmd, "handle");
|
|
846
846
|
await cmd.handle(this.app);
|
|
847
847
|
}
|
|
848
|
-
static async parse(kernel, config = {}, extraCommands = []) {
|
|
848
|
+
static async parse(kernel, config = {}, extraCommands = [], returnExit = false) {
|
|
849
|
+
let exitCode = 0;
|
|
850
|
+
if (typeof extraCommands === "boolean") {
|
|
851
|
+
returnExit = extraCommands;
|
|
852
|
+
extraCommands = [];
|
|
853
|
+
}
|
|
849
854
|
const commands = config.baseCommands?.concat(extraCommands)?.map((e) => new e(kernel.app, kernel));
|
|
850
855
|
const cli = new Musket(kernel.app, kernel, commands, config.resolver, config.tsDownConfig).configure(config);
|
|
851
856
|
if (config.cliName) cli.cliName = config.cliName;
|
|
852
857
|
const command = (await cli.build()).exitOverride((e) => {
|
|
858
|
+
exitCode = e.exitCode;
|
|
853
859
|
if (e.exitCode <= 0) return;
|
|
854
860
|
__h3ravel_shared.Logger.log("Unknown command or argument.", "white");
|
|
855
861
|
__h3ravel_shared.Logger.log([
|
|
@@ -858,8 +864,9 @@ var Musket = class Musket {
|
|
|
858
864
|
["to see available commands.", "white"]
|
|
859
865
|
], " ");
|
|
860
866
|
});
|
|
861
|
-
if (!config.skipParsing) await command.parseAsync(process.argv).catch((e) =>
|
|
867
|
+
if (!config.skipParsing) await command.parseAsync(process.argv).catch((e) => void 0);
|
|
862
868
|
if (cli.app) cli.app.musket = cli;
|
|
869
|
+
if (returnExit === true) return exitCode;
|
|
863
870
|
return command;
|
|
864
871
|
}
|
|
865
872
|
};
|
|
@@ -908,8 +915,8 @@ var Kernel = class Kernel {
|
|
|
908
915
|
/**
|
|
909
916
|
* Run the CLI IO
|
|
910
917
|
*/
|
|
911
|
-
async run() {
|
|
912
|
-
return await Musket.parse(this, this.config, this.getRegisteredCommands());
|
|
918
|
+
async run(returnExit) {
|
|
919
|
+
return await Musket.parse(this, this.config, this.getRegisteredCommands(), returnExit);
|
|
913
920
|
}
|
|
914
921
|
/**
|
|
915
922
|
* Set the configuration for the CLI
|
package/dist/index.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ declare class Kernel<A extends Application = Application> {
|
|
|
156
156
|
/**
|
|
157
157
|
* Run the CLI IO
|
|
158
158
|
*/
|
|
159
|
-
run(): Promise<commander0.Command>;
|
|
159
|
+
run<E extends boolean = false>(returnExit?: E): Promise<E extends true ? number : commander0.Command>;
|
|
160
160
|
/**
|
|
161
161
|
* Set the configuration for the CLI
|
|
162
162
|
*/
|
|
@@ -440,8 +440,8 @@ declare class Musket {
|
|
|
440
440
|
rebuild(name: string): Promise<void>;
|
|
441
441
|
private makeOption;
|
|
442
442
|
private handle;
|
|
443
|
-
static parse(kernel: Kernel, config: InitConfig): Promise<Command$1>;
|
|
444
|
-
static parse(kernel: Kernel, config: InitConfig, commands: typeof Command[]): Promise<Command$1>;
|
|
443
|
+
static parse<E extends boolean = false>(kernel: Kernel, config: InitConfig, returnExit?: E): Promise<E extends true ? number : Command$1>;
|
|
444
|
+
static parse<E extends boolean = false>(kernel: Kernel, config: InitConfig, commands: typeof Command[], returnExit?: E): Promise<E extends true ? number : Command$1>;
|
|
445
445
|
}
|
|
446
446
|
//#endregion
|
|
447
447
|
//#region src/Contracts/Application.d.ts
|
package/dist/index.js
CHANGED
|
@@ -821,11 +821,17 @@ var Musket = class Musket {
|
|
|
821
821
|
if (this.resolver) return await this.resolver(cmd, "handle");
|
|
822
822
|
await cmd.handle(this.app);
|
|
823
823
|
}
|
|
824
|
-
static async parse(kernel, config = {}, extraCommands = []) {
|
|
824
|
+
static async parse(kernel, config = {}, extraCommands = [], returnExit = false) {
|
|
825
|
+
let exitCode = 0;
|
|
826
|
+
if (typeof extraCommands === "boolean") {
|
|
827
|
+
returnExit = extraCommands;
|
|
828
|
+
extraCommands = [];
|
|
829
|
+
}
|
|
825
830
|
const commands = config.baseCommands?.concat(extraCommands)?.map((e) => new e(kernel.app, kernel));
|
|
826
831
|
const cli = new Musket(kernel.app, kernel, commands, config.resolver, config.tsDownConfig).configure(config);
|
|
827
832
|
if (config.cliName) cli.cliName = config.cliName;
|
|
828
833
|
const command = (await cli.build()).exitOverride((e) => {
|
|
834
|
+
exitCode = e.exitCode;
|
|
829
835
|
if (e.exitCode <= 0) return;
|
|
830
836
|
Logger.log("Unknown command or argument.", "white");
|
|
831
837
|
Logger.log([
|
|
@@ -834,8 +840,9 @@ var Musket = class Musket {
|
|
|
834
840
|
["to see available commands.", "white"]
|
|
835
841
|
], " ");
|
|
836
842
|
});
|
|
837
|
-
if (!config.skipParsing) await command.parseAsync(process.argv).catch((e) =>
|
|
843
|
+
if (!config.skipParsing) await command.parseAsync(process.argv).catch((e) => void 0);
|
|
838
844
|
if (cli.app) cli.app.musket = cli;
|
|
845
|
+
if (returnExit === true) return exitCode;
|
|
839
846
|
return command;
|
|
840
847
|
}
|
|
841
848
|
};
|
|
@@ -884,8 +891,8 @@ var Kernel = class Kernel {
|
|
|
884
891
|
/**
|
|
885
892
|
* Run the CLI IO
|
|
886
893
|
*/
|
|
887
|
-
async run() {
|
|
888
|
-
return await Musket.parse(this, this.config, this.getRegisteredCommands());
|
|
894
|
+
async run(returnExit) {
|
|
895
|
+
return await Musket.parse(this, this.config, this.getRegisteredCommands(), returnExit);
|
|
889
896
|
}
|
|
890
897
|
/**
|
|
891
898
|
* Set the configuration for the CLI
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/musket",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Musket CLI is a framework-agnostic CLI framework designed to allow you build artisan-like CLI apps and for use in the H3ravel framework.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|