bob-core 2.0.0-beta.11 → 2.0.0-beta.12
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/cjs/index.js +1 -1
- package/dist/cjs/{package-CskRjcFl.cjs → package-Crgs52BZ.cjs} +1 -1
- package/dist/cjs/src/Command.d.ts +1 -1
- package/dist/cjs/src/CommandIO.d.ts +6 -6
- package/dist/cjs/src/CommandParser.d.ts +1 -1
- package/dist/cjs/src/Logger.d.ts +5 -5
- package/dist/cjs/src/contracts/LoggerContract.d.ts +5 -5
- package/dist/cjs/src/lib/types.d.ts +2 -2
- package/dist/cjs/src/lib/valueConverter.d.ts +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/{package-CMaeADGz.js → package-B07Xl_ue.js} +1 -1
- package/dist/esm/src/Command.d.ts +1 -1
- package/dist/esm/src/CommandIO.d.ts +6 -6
- package/dist/esm/src/CommandParser.d.ts +1 -1
- package/dist/esm/src/Logger.d.ts +5 -5
- package/dist/esm/src/contracts/LoggerContract.d.ts +5 -5
- package/dist/esm/src/lib/types.d.ts +2 -2
- package/dist/esm/src/lib/valueConverter.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@ ${a.yellow("Options")}:`);for(const l of i){const d=N(h-l.optionWithAlias.length
|
|
|
12
12
|
${a.yellow("Examples")}:`);let l=process.argv[0].split("/").pop();l==="node"&&(l+=" "+process.argv[1].split("/").pop());for(const[d,p]of this.commandsExamples.entries())d>0&&this.io.log(""),this.io.log(` ${p.description}
|
|
13
13
|
`),this.io.log(` ${a.green(`${l} ${p.command}`)}`)}return-1}}class R{_command;description="";group;commandsExamples=[];get command(){return this._command}ctx;io;logger;parser;disablePromptingFlag=!1;_preHandler;_handler;tmp;defaultOptions(){return[new ee]}newCommandParser(e){return new M({io:e.io,options:e.options,arguments:e.arguments})}newCommandIO(e){return new I(e.logger)}constructor(e,t){this._command=e,this.description=t?.description??"",this.group=t?.group,this.tmp={options:t?.options??{},arguments:t?.arguments??{}};const n=this.defaultOptions();if(n.length>0)for(const s of n)this.tmp.options[s.option]=s}disablePrompting(){return this.disablePromptingFlag=!0,this}preHandler(e){return this._preHandler=e,this}handler(e){return this._handler=e,this}options(e){return this.tmp={options:{...this.tmp?.options??{},...e},arguments:this.tmp?.arguments??{}},this}arguments(e){return this.tmp={options:this.tmp?.options??{},arguments:{...this.tmp?.arguments??{},...e}},this}async run(e){if(!this._handler&&!this.handle)throw new Error(`No handler defined for command ${this.command||"(unknown)"}`);let t;if(this.ctx=e.ctx,this.logger=e.logger,this.io=this.newCommandIO({logger:e.logger}),e&&"args"in e){const i=this.tmp?.options??{};for(const o of this.defaultOptions())o.option in i||(i[o.option]=o);this.parser=this.newCommandParser({io:this.io,options:i,arguments:this.tmp?.arguments??{}}),t=this.parser.init(e.args);for(const o of this.defaultOptions())if(t.options[o.option]===!0){const u=await o.handler.call(this);if(u&&u!==0)return u}this.disablePromptingFlag&&this.parser.disablePrompting(),await this.parser.validate()}else t={options:e.options,arguments:e.arguments};const n=this.preHandle?await this.preHandle():null;if(n&&n!==0)return n;if(!this._handler&&this.handle)this._handler=this.handle.bind(this);else if(!this._handler)throw new Error(`No handler defined for command ${this.command||"(unknown)"}`);return await this._handler(e.ctx,t)??0}}class w extends M{command;constructor(e){const t=w.parseSignature(e.signature,e.helperDefinitions,e.defaultOptions);super({io:e.io,options:t.options,arguments:t.arguments}),this.command=t.command}static parseSignature(e,t,n){const[s,...i]=e.split(/\{(.*?)\}/g).map(m=>m.trim()).filter(Boolean),o={},u={};for(const m of i){const{name:h,isOption:l,definition:d}=w.parseParamSignature(m,t);l?o[h]=d:u[h]=d}for(const m of n)o[m.option]={type:m.type,required:m.required,alias:m.alias,variadic:m.variadic??!1,description:m.description,default:m.default??null};return{command:s,options:o,arguments:u}}static parseParamSignature(e,t){let n=e,s=!1;const i={required:!0,type:"string",description:void 0,default:null,variadic:!1};if(n.includes(":")){const[o,u]=n.split(":");n=o.trim(),i.description=u.trim()}if(n.includes("=")){const[o,u]=n.split("=");n=o.trim(),i.default=u.trim(),i.required=!1,typeof i.default=="string"&&!i.default.length?i.default=null:i.default==="true"?(i.default=!0,i.type="boolean"):i.default==="false"&&(i.default=!1,i.type="boolean")}else n.startsWith("--")&&(i.required=!1,i.default=!1,i.type="boolean");if(n.includes("|")){const[o,...u]=n.split("|");n=o.trim(),i.alias=u.map(m=>m.trim())}return n.startsWith("--")&&(s=!0,n=n.slice(2)),i.default==="*"&&(i.default=[],i.type=["string"]),n.endsWith("?")&&(i.required=!1,n=n.slice(0,-1)),n.endsWith("*")&&(i.type=["string"],i.variadic=!0,i.default=[],n=n.slice(0,-1)),i.description=i.description??t[n]??t[`--${n}`],{name:n,isOption:s,definition:i}}}class Ce extends R{helperDefinitions={};get command(){return this.parser?this.parser.command:this.signature.split(" ")[0]}newCommandParser(e){return new w({io:e.io,signature:this.signature,helperDefinitions:this.helperDefinitions,defaultOptions:this.defaultOptions()})}constructor(){super("")}option(e,t=null){return this.parser instanceof w?this.parser.option(e)??t:t}argument(e,t=null){return this.parser instanceof w?this.parser.argument(e)??t:t}async askForConfirmation(...e){return this.io.askForConfirmation(...e)}async askForInput(...e){return this.io.askForInput(...e)}async askForSelect(...e){return this.io.askForSelect(...e)}newLoader(...e){return this.io.newLoader(...e)}}class q{level;constructor(e={}){this.level=e.level??"info"}shouldLog(e){const t=["debug","info","warn","error"],n=t.indexOf(this.level);return t.indexOf(e)>=n}setLevel(e){this.level=e}getLevel(){return this.level}log(...e){console.log(...e)}info(...e){this.shouldLog("info")&&console.log(...e)}warn(...e){this.shouldLog("warn")&&console.warn(...e)}error(...e){this.shouldLog("error")&&console.error(...e)}debug(...e){this.shouldLog("debug")&&console.log(...e)}}class te{commands={};io;logger;get CommandIOClass(){return I}constructor(e){this.logger=e??new q,this.io=new this.CommandIOClass(this.logger)}getAvailableCommands(){return Object.keys(this.commands)}getCommands(){return Object.values(this.commands)}importFile=async e=>(await import(e)).default;commandResolver=async e=>{let t=await this.importFile(e);if(!t)throw new Error(`The command at path ${e} does not have a default export.`);return t&&typeof t=="object"&&"default"in t&&(t=t.default),typeof t=="function"?new t:t instanceof R?t:null};withCommandResolver(e){return this.commandResolver=e,this}withFileImporter(e){return this.importFile=e,this}registerCommand(e,t=!1){const n=e.command;if(!n)throw new Error("Command signature is invalid, it must have a command name.");if(!t&&this.commands[n])throw new Error(`Command ${n} already registered.`);this.commands[n]=e}async loadCommandsPath(e){for await(const t of this.listCommandsFiles(e))try{const n=await this.commandResolver(t);n instanceof R&&this.registerCommand(n)}catch(n){throw new Error(`Command ${t} failed to load. ${n}`,{cause:n})}}async runCommand(e,t,...n){const s=typeof t=="string"?this.commands[t]:t,i=typeof t=="string"?t:s.command;if(!s){const o=await this.suggestCommand(i);return o?await this.runCommand(e,o,...n):1}return await s.run({ctx:e,logger:this.logger,args:n})??0}async suggestCommand(e){const t=this.getAvailableCommands(),{bestMatch:n,bestMatchIndex:s,ratings:i}=le.findBestMatch(e,t),o=i.filter(u=>u.rating>.3).map(u=>u.target);if(n.rating>0&&o.length<=1||n.rating>.7&&o.length>1){const u=t[s];return await this.askRunSimilarCommand(e,u)?u:null}if(o.length){this.io.error(`${a.bgRed(" ERROR ")} Command ${a.yellow(e)} not found.
|
|
14
14
|
`);const u=await this.io.askForSelect(a.green("Did you mean to run one of these commands instead?"),o);if(u)return u}throw new Z(e)}async askRunSimilarCommand(e,t){return this.io.error(`${a.bgRed(" ERROR ")} Command ${a.yellow(e)} not found.
|
|
15
|
-
`),this.io.askForConfirmation(`${a.green(`Do you want to run ${a.yellow(t)} instead?`)} `)}async*listCommandsFiles(e){const t=ae.readdirSync(e,{withFileTypes:!0});for(const n of t){const s=D.resolve(e,n.name);if(n.isDirectory())yield*this.listCommandsFiles(D.resolve(e,n.name));else{if(!s.endsWith(".ts")&&!s.endsWith(".js")&&!s.endsWith(".mjs")&&!s.endsWith(".cjs"))continue;yield s}}}}class ne{logger;constructor(e){this.logger=e}handle(e){if(e instanceof b)return e.pretty(this.logger),-1;throw e}}class Oe extends R{constructor(e){super("help",{description:a.bold("Show help information about the CLI and its commands")}),this.opts=e}async handle(){const e=this.opts.commandRegistry.getCommands(),t=this.opts.cliName??"Bob CLI",n=this.opts.cliVersion??"0.0.0",s=(await Promise.resolve().then(()=>require("./package-
|
|
15
|
+
`),this.io.askForConfirmation(`${a.green(`Do you want to run ${a.yellow(t)} instead?`)} `)}async*listCommandsFiles(e){const t=ae.readdirSync(e,{withFileTypes:!0});for(const n of t){const s=D.resolve(e,n.name);if(n.isDirectory())yield*this.listCommandsFiles(D.resolve(e,n.name));else{if(!s.endsWith(".ts")&&!s.endsWith(".js")&&!s.endsWith(".mjs")&&!s.endsWith(".cjs"))continue;yield s}}}}class ne{logger;constructor(e){this.logger=e}handle(e){if(e instanceof b)return e.pretty(this.logger),-1;throw e}}class Oe extends R{constructor(e){super("help",{description:a.bold("Show help information about the CLI and its commands")}),this.opts=e}async handle(){const e=this.opts.commandRegistry.getCommands(),t=this.opts.cliName??"Bob CLI",n=this.opts.cliVersion??"0.0.0",s=(await Promise.resolve().then(()=>require("./package-Crgs52BZ.cjs")))?.default?.version??"0.0.0";this.io.log(`${t} ${a.green(n)} (core: ${a.yellow(s)})
|
|
16
16
|
|
|
17
17
|
${a.yellow("Usage")}:
|
|
18
18
|
command [options] [arguments]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="bob-core",t="2.0.0-beta.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="bob-core",t="2.0.0-beta.12",s="BOB Core",i="module",n=!1,r=["dist/**"],o={".":{import:"./dist/esm/index.js",require:"./dist/cjs/index.js"}},c={"*":{"*":["./dist/cjs/*.d.ts"]}},p={start:"node -r @swc-node/register debug/main.ts",build:"rimraf ./dist && vite build",typecheck:"tsc --noEmit",prepack:"npm run build",test:"vitest run",lint:"eslint .","lint:fix":"eslint . --fix"},d="Léo Hubert",l="ISC",a={"@eslint/js":"^9.37.0","@faker-js/faker":"^10.0.0","@swc-node/register":"^1.11.1","@trivago/prettier-plugin-sort-imports":"^5.2.2","@types/minimist":"^1.2.5","@types/node":"^20.14.5","@types/prompts":"^2.4.9","@types/string-similarity":"^4.0.2","@vitest/coverage-v8":"^3.2.4",eslint:"^9.37.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4",prettier:"^3.6.2",rimraf:"^6.0.1",tsx:"^4.20.6",typescript:"^5.7.3","typescript-eslint":"^8.46.0",vite:"^7.1.6","vite-plugin-dts":"^4.5.4",vitest:"^3.2.4"},m={chalk:"^5.6.2",minimist:"^1.2.8",prompts:"^2.4.2","string-similarity":"^4.0.4"},u={name:e,version:t,description:s,type:i,sideEffects:n,files:r,exports:o,typesVersions:c,scripts:p,author:d,license:l,devDependencies:a,dependencies:m};exports.author=d;exports.default=u;exports.dependencies=m;exports.description=s;exports.devDependencies=a;exports.exports=o;exports.files=r;exports.license=l;exports.name=e;exports.scripts=p;exports.sideEffects=n;exports.type=i;exports.typesVersions=c;exports.version=t;
|
|
@@ -21,7 +21,7 @@ export type CommandExample = {
|
|
|
21
21
|
description: string;
|
|
22
22
|
command: string;
|
|
23
23
|
};
|
|
24
|
-
export declare class Command<C =
|
|
24
|
+
export declare class Command<C extends ContextDefinition = ContextDefinition, Options extends OptionsSchema = OptionsSchema, Arguments extends ArgumentsSchema = ArgumentsSchema> {
|
|
25
25
|
readonly _command: string;
|
|
26
26
|
readonly description: string;
|
|
27
27
|
readonly group?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from './Logger.js';
|
|
2
2
|
export type SelectOption = {
|
|
3
3
|
title: string;
|
|
4
|
-
value?:
|
|
4
|
+
value?: any;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
6
|
selected?: boolean | undefined;
|
|
7
7
|
description?: string | undefined;
|
|
@@ -12,11 +12,11 @@ export declare class CommandIO {
|
|
|
12
12
|
/**
|
|
13
13
|
* Logger methods
|
|
14
14
|
*/
|
|
15
|
-
log(...args:
|
|
16
|
-
info(...args:
|
|
17
|
-
warn(...args:
|
|
18
|
-
error(...args:
|
|
19
|
-
debug(...args:
|
|
15
|
+
log(...args: any[]): void;
|
|
16
|
+
info(...args: any[]): void;
|
|
17
|
+
warn(...args: any[]): void;
|
|
18
|
+
error(...args: any[]): void;
|
|
19
|
+
debug(...args: any[]): void;
|
|
20
20
|
/**
|
|
21
21
|
* Prompt utils
|
|
22
22
|
*/
|
|
@@ -21,7 +21,7 @@ export declare class CommandParser<Options extends OptionsSchema, Arguments exte
|
|
|
21
21
|
* Parses raw command-line arguments into structured options and arguments
|
|
22
22
|
* @param args - Raw command line arguments (typically from process.argv.slice(2))
|
|
23
23
|
* @returns Object containing parsed options and arguments
|
|
24
|
-
* @throws {InvalidOption} If an
|
|
24
|
+
* @throws {InvalidOption} If an ynaan option is provided
|
|
25
25
|
* @throws {BadCommandOption} If a value cannot be converted to the expected type
|
|
26
26
|
*/
|
|
27
27
|
init(args: string[]): {
|
package/dist/cjs/src/Logger.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export declare class Logger implements LoggerContract {
|
|
|
8
8
|
private shouldLog;
|
|
9
9
|
setLevel(level: LogLevel): void;
|
|
10
10
|
getLevel(): LogLevel;
|
|
11
|
-
log(...args:
|
|
12
|
-
info(...args:
|
|
13
|
-
warn(...args:
|
|
14
|
-
error(...args:
|
|
15
|
-
debug(...args:
|
|
11
|
+
log(...args: any[]): void;
|
|
12
|
+
info(...args: any[]): void;
|
|
13
|
+
warn(...args: any[]): void;
|
|
14
|
+
error(...args: any[]): void;
|
|
15
|
+
debug(...args: any[]): void;
|
|
16
16
|
}
|
|
@@ -3,11 +3,11 @@ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
|
3
3
|
* Logger interface defining standard logging methods and level management
|
|
4
4
|
*/
|
|
5
5
|
export interface LoggerContract {
|
|
6
|
-
log(message: string, ...args:
|
|
7
|
-
info(message: string, ...args:
|
|
8
|
-
warn(message: string, ...args:
|
|
9
|
-
error(message: string, ...args:
|
|
10
|
-
debug(message: string, ...args:
|
|
6
|
+
log(message: string, ...args: any[]): void;
|
|
7
|
+
info(message: string, ...args: any[]): void;
|
|
8
|
+
warn(message: string, ...args: any[]): void;
|
|
9
|
+
error(message: string, ...args: any[]): void;
|
|
10
|
+
debug(message: string, ...args: any[]): void;
|
|
11
11
|
setLevel(level: LogLevel): void;
|
|
12
12
|
getLevel(): LogLevel;
|
|
13
13
|
}
|
|
@@ -5,7 +5,7 @@ export type OptionDefinition = {
|
|
|
5
5
|
alias?: string | Array<string>;
|
|
6
6
|
required?: boolean;
|
|
7
7
|
secret?: boolean;
|
|
8
|
-
default?:
|
|
8
|
+
default?: any;
|
|
9
9
|
variadic?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export type Option = OptionPrimitive | OptionDefinition;
|
|
@@ -28,4 +28,4 @@ export type ArgumentsSchema = {
|
|
|
28
28
|
export type ArgumentsObject<Arguments extends ArgumentsSchema> = {
|
|
29
29
|
[Key in keyof Arguments]: OptionReturnType<Arguments[Key]>;
|
|
30
30
|
};
|
|
31
|
-
export type ContextDefinition =
|
|
31
|
+
export type ContextDefinition = any;
|
|
@@ -7,4 +7,4 @@ import { OptionPrimitive } from './types.js';
|
|
|
7
7
|
* @param defaultValue - Optional default value if value is null/undefined
|
|
8
8
|
* @returns The converted value
|
|
9
9
|
*/
|
|
10
|
-
export declare function convertValue(value:
|
|
10
|
+
export declare function convertValue(value: any, type: OptionPrimitive, name: string, defaultValue?: any): any;
|
package/dist/esm/index.js
CHANGED
|
@@ -516,7 +516,7 @@ class J {
|
|
|
516
516
|
* Parses raw command-line arguments into structured options and arguments
|
|
517
517
|
* @param args - Raw command line arguments (typically from process.argv.slice(2))
|
|
518
518
|
* @returns Object containing parsed options and arguments
|
|
519
|
-
* @throws {InvalidOption} If an
|
|
519
|
+
* @throws {InvalidOption} If an ynaan option is provided
|
|
520
520
|
* @throws {BadCommandOption} If a value cannot be converted to the expected type
|
|
521
521
|
*/
|
|
522
522
|
init(e) {
|
|
@@ -1155,7 +1155,7 @@ class ye extends F {
|
|
|
1155
1155
|
}), this.opts = e;
|
|
1156
1156
|
}
|
|
1157
1157
|
async handle() {
|
|
1158
|
-
const e = this.opts.commandRegistry.getCommands(), t = this.opts.cliName ?? "Bob CLI", n = this.opts.cliVersion ?? "0.0.0", s = (await import("./package-
|
|
1158
|
+
const e = this.opts.commandRegistry.getCommands(), t = this.opts.cliName ?? "Bob CLI", n = this.opts.cliVersion ?? "0.0.0", s = (await import("./package-B07Xl_ue.js"))?.default?.version ?? "0.0.0";
|
|
1159
1159
|
this.io.log(`${t} ${a.green(n)} (core: ${a.yellow(s)})
|
|
1160
1160
|
|
|
1161
1161
|
${a.yellow("Usage")}:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const t = "bob-core", e = "2.0.0-beta.
|
|
1
|
+
const t = "bob-core", e = "2.0.0-beta.12", s = "BOB Core", i = "module", m = !1, n = ["dist/**"], r = { ".": { import: "./dist/esm/index.js", require: "./dist/cjs/index.js" } }, o = { "*": { "*": ["./dist/cjs/*.d.ts"] } }, c = { start: "node -r @swc-node/register debug/main.ts", build: "rimraf ./dist && vite build", typecheck: "tsc --noEmit", prepack: "npm run build", test: "vitest run", lint: "eslint .", "lint:fix": "eslint . --fix" }, p = "Léo Hubert", d = "ISC", l = { "@eslint/js": "^9.37.0", "@faker-js/faker": "^10.0.0", "@swc-node/register": "^1.11.1", "@trivago/prettier-plugin-sort-imports": "^5.2.2", "@types/minimist": "^1.2.5", "@types/node": "^20.14.5", "@types/prompts": "^2.4.9", "@types/string-similarity": "^4.0.2", "@vitest/coverage-v8": "^3.2.4", eslint: "^9.37.0", "eslint-config-prettier": "^10.1.8", "eslint-plugin-prettier": "^5.5.4", prettier: "^3.6.2", rimraf: "^6.0.1", tsx: "^4.20.6", typescript: "^5.7.3", "typescript-eslint": "^8.46.0", vite: "^7.1.6", "vite-plugin-dts": "^4.5.4", vitest: "^3.2.4" }, a = { chalk: "^5.6.2", minimist: "^1.2.8", prompts: "^2.4.2", "string-similarity": "^4.0.4" }, f = {
|
|
2
2
|
name: t,
|
|
3
3
|
version: e,
|
|
4
4
|
description: s,
|
|
@@ -21,7 +21,7 @@ export type CommandExample = {
|
|
|
21
21
|
description: string;
|
|
22
22
|
command: string;
|
|
23
23
|
};
|
|
24
|
-
export declare class Command<C =
|
|
24
|
+
export declare class Command<C extends ContextDefinition = ContextDefinition, Options extends OptionsSchema = OptionsSchema, Arguments extends ArgumentsSchema = ArgumentsSchema> {
|
|
25
25
|
readonly _command: string;
|
|
26
26
|
readonly description: string;
|
|
27
27
|
readonly group?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from './Logger.js';
|
|
2
2
|
export type SelectOption = {
|
|
3
3
|
title: string;
|
|
4
|
-
value?:
|
|
4
|
+
value?: any;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
6
|
selected?: boolean | undefined;
|
|
7
7
|
description?: string | undefined;
|
|
@@ -12,11 +12,11 @@ export declare class CommandIO {
|
|
|
12
12
|
/**
|
|
13
13
|
* Logger methods
|
|
14
14
|
*/
|
|
15
|
-
log(...args:
|
|
16
|
-
info(...args:
|
|
17
|
-
warn(...args:
|
|
18
|
-
error(...args:
|
|
19
|
-
debug(...args:
|
|
15
|
+
log(...args: any[]): void;
|
|
16
|
+
info(...args: any[]): void;
|
|
17
|
+
warn(...args: any[]): void;
|
|
18
|
+
error(...args: any[]): void;
|
|
19
|
+
debug(...args: any[]): void;
|
|
20
20
|
/**
|
|
21
21
|
* Prompt utils
|
|
22
22
|
*/
|
|
@@ -21,7 +21,7 @@ export declare class CommandParser<Options extends OptionsSchema, Arguments exte
|
|
|
21
21
|
* Parses raw command-line arguments into structured options and arguments
|
|
22
22
|
* @param args - Raw command line arguments (typically from process.argv.slice(2))
|
|
23
23
|
* @returns Object containing parsed options and arguments
|
|
24
|
-
* @throws {InvalidOption} If an
|
|
24
|
+
* @throws {InvalidOption} If an ynaan option is provided
|
|
25
25
|
* @throws {BadCommandOption} If a value cannot be converted to the expected type
|
|
26
26
|
*/
|
|
27
27
|
init(args: string[]): {
|
package/dist/esm/src/Logger.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export declare class Logger implements LoggerContract {
|
|
|
8
8
|
private shouldLog;
|
|
9
9
|
setLevel(level: LogLevel): void;
|
|
10
10
|
getLevel(): LogLevel;
|
|
11
|
-
log(...args:
|
|
12
|
-
info(...args:
|
|
13
|
-
warn(...args:
|
|
14
|
-
error(...args:
|
|
15
|
-
debug(...args:
|
|
11
|
+
log(...args: any[]): void;
|
|
12
|
+
info(...args: any[]): void;
|
|
13
|
+
warn(...args: any[]): void;
|
|
14
|
+
error(...args: any[]): void;
|
|
15
|
+
debug(...args: any[]): void;
|
|
16
16
|
}
|
|
@@ -3,11 +3,11 @@ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
|
3
3
|
* Logger interface defining standard logging methods and level management
|
|
4
4
|
*/
|
|
5
5
|
export interface LoggerContract {
|
|
6
|
-
log(message: string, ...args:
|
|
7
|
-
info(message: string, ...args:
|
|
8
|
-
warn(message: string, ...args:
|
|
9
|
-
error(message: string, ...args:
|
|
10
|
-
debug(message: string, ...args:
|
|
6
|
+
log(message: string, ...args: any[]): void;
|
|
7
|
+
info(message: string, ...args: any[]): void;
|
|
8
|
+
warn(message: string, ...args: any[]): void;
|
|
9
|
+
error(message: string, ...args: any[]): void;
|
|
10
|
+
debug(message: string, ...args: any[]): void;
|
|
11
11
|
setLevel(level: LogLevel): void;
|
|
12
12
|
getLevel(): LogLevel;
|
|
13
13
|
}
|
|
@@ -5,7 +5,7 @@ export type OptionDefinition = {
|
|
|
5
5
|
alias?: string | Array<string>;
|
|
6
6
|
required?: boolean;
|
|
7
7
|
secret?: boolean;
|
|
8
|
-
default?:
|
|
8
|
+
default?: any;
|
|
9
9
|
variadic?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export type Option = OptionPrimitive | OptionDefinition;
|
|
@@ -28,4 +28,4 @@ export type ArgumentsSchema = {
|
|
|
28
28
|
export type ArgumentsObject<Arguments extends ArgumentsSchema> = {
|
|
29
29
|
[Key in keyof Arguments]: OptionReturnType<Arguments[Key]>;
|
|
30
30
|
};
|
|
31
|
-
export type ContextDefinition =
|
|
31
|
+
export type ContextDefinition = any;
|
|
@@ -7,4 +7,4 @@ import { OptionPrimitive } from './types.js';
|
|
|
7
7
|
* @param defaultValue - Optional default value if value is null/undefined
|
|
8
8
|
* @returns The converted value
|
|
9
9
|
*/
|
|
10
|
-
export declare function convertValue(value:
|
|
10
|
+
export declare function convertValue(value: any, type: OptionPrimitive, name: string, defaultValue?: any): any;
|