zod-args-parser 1.2.1 → 1.2.3
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/lib/commonjs/help-message/format-arguments.js +1 -1
- package/lib/commonjs/help-message/format-arguments.js.map +1 -1
- package/lib/commonjs/help-message/format-options.js +1 -1
- package/lib/commonjs/help-message/format-options.js.map +1 -1
- package/lib/commonjs/metadata/get-arguments-metadata.js +1 -1
- package/lib/commonjs/metadata/get-arguments-metadata.js.map +1 -1
- package/lib/commonjs/metadata/get-options-metadata.js +1 -1
- package/lib/commonjs/metadata/get-options-metadata.js.map +1 -1
- package/lib/commonjs/utils.js +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/help-message/format-arguments.js +1 -1
- package/lib/module/help-message/format-arguments.js.map +1 -1
- package/lib/module/help-message/format-options.js +1 -1
- package/lib/module/help-message/format-options.js.map +1 -1
- package/lib/module/metadata/get-arguments-metadata.js +1 -1
- package/lib/module/metadata/get-arguments-metadata.js.map +1 -1
- package/lib/module/metadata/get-options-metadata.js +1 -1
- package/lib/module/metadata/get-options-metadata.js.map +1 -1
- package/lib/module/utils.js +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/help-message/format-arguments.d.ts.map +1 -1
- package/lib/typescript/help-message/format-options.d.ts.map +1 -1
- package/lib/typescript/utils.d.ts +2 -0
- package/lib/typescript/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/help-message/format-arguments.ts +4 -3
- package/src/help-message/format-options.ts +7 -5
- package/src/metadata/get-arguments-metadata.ts +1 -1
- package/src/metadata/get-options-metadata.ts +1 -1
- package/src/utils.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatHelpMsgArguments=formatHelpMsgArguments;var _utils=require("../utils.js");function formatHelpMsgArguments(argsMetadata,c,longest){if(!argsMetadata.length)return"";let msg=c.title(" ARGUMENTS")+(0,_utils.ln)(1);for(const metadata of argsMetadata){const defaultStr=typeof metadata.defaultValue!=="undefined"?`(default: ${metadata.defaultValueAsString})`:"";const spacing=longest+2-metadata.name.length;const normalizeDesc=metadata.description.replace(/\n/g,"\n"+(0,_utils.indent)(longest+6)+c.punctuation("└"));msg+=(0,_utils.concat)((0,_utils.indent)(2)+c.argument(metadata.name),(0,_utils.indent)(spacing),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatHelpMsgArguments=formatHelpMsgArguments;var _utils=require("../utils.js");function formatHelpMsgArguments(argsMetadata,c,longest){if(!argsMetadata.length)return"";let msg=c.title(" ARGUMENTS")+(0,_utils.ln)(1);for(const metadata of argsMetadata){const defaultStr=typeof metadata.defaultValue!=="undefined"?`(default: ${metadata.defaultValueAsString})`:"";const spacing=longest+2-metadata.name.length;const normalizeDesc=metadata.description.replace(/\n/g,"\n"+(0,_utils.indent)(longest+6)+c.punctuation("└"));const defaultOrOptional=defaultStr?c.default(defaultStr):metadata.optional?c.optional("(optional)"):"";msg+=(0,_utils.concat)((0,_utils.indent)(2)+c.argument(metadata.name),(0,_utils.indent)(spacing),(0,_utils.insertAtEndOfFirstLine)(c.description(normalizeDesc),defaultOrOptional),(0,_utils.ln)(1));if(metadata.example){const normalizeExample=metadata.example.replace(/\n/g,"\n"+(0,_utils.indent)(longest+16));msg+=(0,_utils.concat)((0,_utils.indent)(longest+5),c.punctuation("└")+c.exampleTitle("Example:"),c.example(normalizeExample)+(0,_utils.ln)(1));}}msg+=(0,_utils.ln)(1);return msg;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","formatHelpMsgArguments","argsMetadata","c","longest","length","msg","title","ln","metadata","defaultStr","defaultValue","defaultValueAsString","spacing","name","normalizeDesc","description","replace","indent","punctuation","
|
|
1
|
+
{"version":3,"names":["_utils","require","formatHelpMsgArguments","argsMetadata","c","longest","length","msg","title","ln","metadata","defaultStr","defaultValue","defaultValueAsString","spacing","name","normalizeDesc","description","replace","indent","punctuation","defaultOrOptional","default","optional","concat","argument","insertAtEndOfFirstLine","example","normalizeExample","exampleTitle"],"sourceRoot":"../../../src/help-message","sources":["format-arguments.ts"],"sourcesContent":["import { concat, indent, insertAtEndOfFirstLine, ln } from \"../utils.js\";\n\nimport type { ArgumentMetadata } from \"../metadata/metadata-types.js\";\nimport type { HelpMsgStyle } from \"../types.js\";\n\nexport function formatHelpMsgArguments(argsMetadata: ArgumentMetadata[], c: HelpMsgStyle, longest: number): string {\n if (!argsMetadata.length) return \"\";\n\n let msg = c.title(\" ARGUMENTS\") + ln(1);\n\n for (const metadata of argsMetadata) {\n const defaultStr =\n typeof metadata.defaultValue !== \"undefined\" ? `(default: ${metadata.defaultValueAsString})` : \"\";\n\n const spacing = longest + 2 - metadata.name.length;\n const normalizeDesc = metadata.description.replace(/\\n/g, \"\\n\" + indent(longest + 6) + c.punctuation(\"└\"));\n const defaultOrOptional = defaultStr ? c.default(defaultStr) : metadata.optional ? c.optional(\"(optional)\") : \"\";\n\n msg += concat(\n indent(2) + c.argument(metadata.name),\n indent(spacing),\n insertAtEndOfFirstLine(c.description(normalizeDesc), defaultOrOptional),\n ln(1),\n );\n\n if (metadata.example) {\n const normalizeExample = metadata.example.replace(/\\n/g, \"\\n\" + indent(longest + 16));\n msg += concat(\n indent(longest + 5),\n c.punctuation(\"└\") + c.exampleTitle(\"Example:\"),\n c.example(normalizeExample) + ln(1),\n );\n }\n }\n\n msg += ln(1);\n\n return msg;\n}\n"],"mappings":"4HAAA,IAAAA,MAAA,CAAAC,OAAA,gBAKO,QAAS,CAAAC,sBAAsBA,CAACC,YAAgC,CAAEC,CAAe,CAAEC,OAAe,CAAU,CACjH,GAAI,CAACF,YAAY,CAACG,MAAM,CAAE,MAAO,EAAE,CAEnC,GAAI,CAAAC,GAAG,CAAGH,CAAC,CAACI,KAAK,CAAC,YAAY,CAAC,CAAG,GAAAC,SAAE,EAAC,CAAC,CAAC,CAEvC,IAAK,KAAM,CAAAC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CAAC,CAACyB,YAAY,CAAC,UAAU,CAAC,CAC/CzB,CAAC,CAACuB,OAAO,CAACC,gBAAgB,CAAC,CAAG,GAAAnB,SAAE,EAAC,CAAC,CACpC,CAAC,CACH,CACF,CAEAF,GAAG,EAAI,GAAAE,SAAE,EAAC,CAAC,CAAC,CAEZ,MAAO,CAAAF,GAAG,CACZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatHelpMsgOptions=formatHelpMsgOptions;var _utils=require("../utils.js");function formatHelpMsgOptions(optionsMetadata,c,longest){if(!optionsMetadata.length)return"";let msg=c.title(" OPTIONS")+(0,_utils.ln)(1);for(const metadata of optionsMetadata){const names=metadata.aliasesAsArgs.concat([metadata.nameAsArg]);const normalizeDesc=metadata.description.replace(/\n/g,"\n"+(0,_utils.indent)(longest+
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatHelpMsgOptions=formatHelpMsgOptions;var _utils=require("../utils.js");function formatHelpMsgOptions(optionsMetadata,c,longest){if(!optionsMetadata.length)return"";let msg=c.title(" OPTIONS")+(0,_utils.ln)(1);for(const metadata of optionsMetadata){const names=metadata.aliasesAsArgs.concat([metadata.nameAsArg]);const normalizeDesc=metadata.description.replace(/\n/g,"\n"+(0,_utils.indent)(longest+6)+c.punctuation("└"));const defaultStr=typeof metadata.defaultValue!=="undefined"?`(default: ${metadata.defaultValueAsString})`:"";const optLength=names.join(", ").length+metadata.placeholder.length;const spacing=longest+1-optLength;const coloredNames=names.map(name=>c.option(name)).join(c.punctuation(", "));const defaultOrOptional=defaultStr?c.default(defaultStr):metadata.optional?c.optional("(optional)"):"";msg+=(0,_utils.concat)((0,_utils.indent)(2)+coloredNames,c.placeholder(metadata.placeholder),(0,_utils.indent)(spacing),(0,_utils.insertAtEndOfFirstLine)(c.description(normalizeDesc),defaultOrOptional),(0,_utils.ln)(1));if(metadata.example){const normalizeExample=metadata.example.replace(/\n/g,"\n"+(0,_utils.indent)(longest+16));msg+=(0,_utils.concat)((0,_utils.indent)(longest+6)+c.punctuation("└")+c.exampleTitle("Example:"),c.example(normalizeExample)+(0,_utils.ln)(1));}}msg+=(0,_utils.ln)(1);return msg;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","formatHelpMsgOptions","optionsMetadata","c","longest","length","msg","title","ln","metadata","names","aliasesAsArgs","concat","nameAsArg","normalizeDesc","description","replace","indent","punctuation","defaultStr","defaultValue","defaultValueAsString","optLength","join","placeholder","spacing","coloredNames","map","name","option","default","optional","example","normalizeExample","exampleTitle"],"sourceRoot":"../../../src/help-message","sources":["format-options.ts"],"sourcesContent":["import { concat, indent, ln } from \"../utils.js\";\n\nimport type { OptionMetadata } from \"../metadata/metadata-types.js\";\nimport type { HelpMsgStyle } from \"../types.js\";\n\nexport function formatHelpMsgOptions(optionsMetadata: OptionMetadata[], c: HelpMsgStyle, longest: number): string {\n if (!optionsMetadata.length) return \"\";\n\n let msg = c.title(\" OPTIONS\") + ln(1);\n\n for (const metadata of optionsMetadata) {\n const names = metadata.aliasesAsArgs.concat([metadata.nameAsArg]);\n const normalizeDesc = metadata.description.replace(/\\n/g, \"\\n\" + indent(longest +
|
|
1
|
+
{"version":3,"names":["_utils","require","formatHelpMsgOptions","optionsMetadata","c","longest","length","msg","title","ln","metadata","names","aliasesAsArgs","concat","nameAsArg","normalizeDesc","description","replace","indent","punctuation","defaultStr","defaultValue","defaultValueAsString","optLength","join","placeholder","spacing","coloredNames","map","name","option","defaultOrOptional","default","optional","insertAtEndOfFirstLine","example","normalizeExample","exampleTitle"],"sourceRoot":"../../../src/help-message","sources":["format-options.ts"],"sourcesContent":["import { concat, indent, insertAtEndOfFirstLine, ln } from \"../utils.js\";\n\nimport type { OptionMetadata } from \"../metadata/metadata-types.js\";\nimport type { HelpMsgStyle } from \"../types.js\";\n\nexport function formatHelpMsgOptions(optionsMetadata: OptionMetadata[], c: HelpMsgStyle, longest: number): string {\n if (!optionsMetadata.length) return \"\";\n\n let msg = c.title(\" OPTIONS\") + ln(1);\n\n for (const metadata of optionsMetadata) {\n const names = metadata.aliasesAsArgs.concat([metadata.nameAsArg]);\n const normalizeDesc = metadata.description.replace(/\\n/g, \"\\n\" + indent(longest + 6) + c.punctuation(\"└\"));\n const defaultStr =\n typeof metadata.defaultValue !== \"undefined\" ? `(default: ${metadata.defaultValueAsString})` : \"\";\n\n const optLength = names.join(\", \").length + metadata.placeholder.length;\n const spacing = longest + 1 - optLength;\n\n const coloredNames = names.map(name => c.option(name)).join(c.punctuation(\", \"));\n\n const defaultOrOptional = defaultStr ? c.default(defaultStr) : metadata.optional ? c.optional(\"(optional)\") : \"\";\n\n msg += concat(\n indent(2) + coloredNames,\n c.placeholder(metadata.placeholder),\n indent(spacing),\n insertAtEndOfFirstLine(c.description(normalizeDesc), defaultOrOptional),\n ln(1),\n );\n\n if (metadata.example) {\n const normalizeExample = metadata.example.replace(/\\n/g, \"\\n\" + indent(longest + 16));\n msg += concat(\n indent(longest + 6) + c.punctuation(\"└\") + c.exampleTitle(\"Example:\"),\n c.example(normalizeExample) + ln(1),\n );\n }\n }\n\n msg += ln(1);\n\n return msg;\n}\n"],"mappings":"wHAAA,IAAAA,MAAA,CAAAC,OAAA,gBAKO,QAAS,CAAAC,oBAAoBA,CAACC,eAAiC,CAAEC,CAAe,CAAEC,OAAe,CAAU,CAChH,GAAI,CAACF,eAAe,CAACG,MAAM,CAAE,MAAO,EAAE,CAEtC,GAAI,CAAAC,GAAG,CAAGH,CAAC,CAACI,KAAK,CAAC,UAAU,CAAC,CAAG,GAAAC,SAAE,EAAC,CAAC,CAAC,CAErC,IAAK,KAAM,CAAAC,QAAQ,GAAI,CAAAP,eAAe,CAAE,CACtC,KAAM,CAAAQ,KAAK,CAAGD,QAAQ,CAACE,aAAa,CAACC,MAAM,CAAC,CAACH,QAAQ,CAACI,SAAS,CAAC,CAAC,CACjE,KAAM,CAAAC,aAAa,CAAGL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AACyB,OAAO,CAAClB,OAAO,CAAC,KAAK,CAAE,IAAI,CAAG,GAAAC,aAAM,EAACb,OAAO,CAAG,EAAE,CAAC,CAAC,CACrFE,GAAG,EAAI,GAAAM,aAAM,EACX,GAAAK,aAAM,EAACb,OAAO,CAAG,CAAC,CAAC,CAAGD,CAAC,CAACe,WAAW,CAAC,GAAG,CAAC,CAAGf,CAAC,CAACiC,YAAY,CAAC,UAAU,CAAC,CACrEjC,CAAC,CAAC+B,OAAO,CAACC,gBAAgB,CAAC,CAAG,GAAA3B,SAAE,EAAC,CAAC,CACpC,CAAC,CACH,CACF,CAEAF,GAAG,EAAI,GAAAE,SAAE,EAAC,CAAC,CAAC,CAEZ,MAAO,CAAAF,GAAG,CACZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getArgumentsMetadata=getArgumentsMetadata;var _utils=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getArgumentsMetadata=getArgumentsMetadata;var _utils=require("../utils.js");var _zodUtils=require("../zod-utils.js");function getArgumentsMetadata(args){const outputMetadata=[];for(const arg of args){const defaultValue=(0,_zodUtils.schemaDefaultValue)(arg.type);outputMetadata.push({name:arg.name,description:arg.description??(0,_zodUtils.schemaDescription)(arg.type)??"",defaultValue,defaultValueAsString:(0,_utils.stringifyValue)(defaultValue),optional:(0,_zodUtils.isOptionalSchema)(arg.type),example:arg.example??"",type:arg.type});}return outputMetadata;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","_zodUtils","getArgumentsMetadata","args","outputMetadata","arg","defaultValue","schemaDefaultValue","type","push","name","description","schemaDescription","defaultValueAsString","stringifyValue","optional","isOptionalSchema","example"],"sourceRoot":"../../../src/metadata","sources":["get-arguments-metadata.ts"],"sourcesContent":["import { stringifyValue } from \"
|
|
1
|
+
{"version":3,"names":["_utils","require","_zodUtils","getArgumentsMetadata","args","outputMetadata","arg","defaultValue","schemaDefaultValue","type","push","name","description","schemaDescription","defaultValueAsString","stringifyValue","optional","isOptionalSchema","example"],"sourceRoot":"../../../src/metadata","sources":["get-arguments-metadata.ts"],"sourcesContent":["import { stringifyValue } from \"../utils.js\";\nimport { isOptionalSchema, schemaDefaultValue, schemaDescription } from \"../zod-utils.js\";\n\nimport type { Argument } from \"../types.js\";\nimport type { ArgumentMetadata } from \"./metadata-types.js\";\n\nexport function getArgumentsMetadata(args: Argument[]): ArgumentMetadata[] {\n const outputMetadata: ArgumentMetadata[] = [];\n\n for (const arg of args) {\n const defaultValue = schemaDefaultValue(arg.type);\n\n outputMetadata.push({\n name: arg.name,\n description: arg.description ?? schemaDescription(arg.type) ?? \"\",\n defaultValue,\n defaultValueAsString: stringifyValue(defaultValue),\n optional: isOptionalSchema(arg.type),\n example: arg.example ?? \"\",\n type: arg.type,\n });\n }\n\n return outputMetadata;\n}\n"],"mappings":"wHAAA,IAAAA,MAAA,CAAAC,OAAA,gBACA,IAAAC,SAAA,CAAAD,OAAA,oBAKO,QAAS,CAAAE,oBAAoBA,CAACC,IAAgB,CAAsB,CACzE,KAAM,CAAAC,cAAkC,CAAG,EAAE,CAE7C,IAAK,KAAM,CAAAC,GAAG,GAAI,CAAAF,IAAI,CAAE,CACtB,KAAM,CAAAG,YAAY,CAAG,GAAAC,4BAAkB,EAACF,GAAG,CAACG,IAAI,CAAC,CAEjDJ,cAAc,CAACK,IAAI,CAAC,CAClBC,IAAI,CAAEL,GAAG,CAACK,IAAI,CACdC,WAAW,CAAEN,GAAG,CAACM,WAAW,EAAI,GAAAC,2BAAiB,EAACP,GAAG,CAACG,IAAI,CAAC,EAAI,EAAE,CACjEF,YAAY,CACZO,oBAAoB,CAAE,GAAAC,qBAAc,EAACR,YAAY,CAAC,CAClDS,QAAQ,CAAE,GAAAC,0BAAgB,EAACX,GAAG,CAACG,IAAI,CAAC,CACpCS,OAAO,CAAEZ,GAAG,CAACY,OAAO,EAAI,EAAE,CAC1BT,IAAI,CAAEH,GAAG,CAACG,IACZ,CAAC,CAAC,CACJ,CAEA,MAAO,CAAAJ,cAAc,CACvB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getOptionsMetadata=getOptionsMetadata;var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getOptionsMetadata=getOptionsMetadata;var _parserHelpers=require("../parser/parse/parser-helpers.js");var _utils=require("../utils.js");var _zodUtils=require("../zod-utils.js");function getOptionsMetadata(options){const outputMetadata=[];if(!options||!options.length)return outputMetadata;for(const option of options){const defaultValue=(0,_zodUtils.schemaDefaultValue)(option.type);const aliases=option.aliases??[];outputMetadata.push({name:option.name,nameAsArg:(0,_parserHelpers.transformOptionToArg)(option.name),aliases,aliasesAsArgs:aliases.map(_parserHelpers.transformOptionToArg),placeholder:option.placeholder??"",description:option.description??(0,_zodUtils.schemaDescription)(option.type)??"",optional:(0,_zodUtils.isOptionalSchema)(option.type),example:option.example??"",defaultValue,defaultValueAsString:(0,_utils.stringifyValue)(defaultValue),type:option.type});}return outputMetadata;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_parserHelpers","require","_utils","_zodUtils","getOptionsMetadata","options","outputMetadata","length","option","defaultValue","schemaDefaultValue","type","aliases","push","name","nameAsArg","transformOptionToArg","aliasesAsArgs","map","placeholder","description","schemaDescription","optional","isOptionalSchema","example","defaultValueAsString","stringifyValue"],"sourceRoot":"../../../src/metadata","sources":["get-options-metadata.ts"],"sourcesContent":["import { transformOptionToArg } from \"../parser/parse/parser-helpers.js\";\nimport { stringifyValue } from \"../utils.js\";\nimport { isOptionalSchema, schemaDefaultValue, schemaDescription } from \"../zod-utils.js\";\n\nimport type { Option } from \"../types.js\";\nimport type { OptionMetadata } from \"./metadata-types.js\";\n\nexport function getOptionsMetadata(options: Option[]): OptionMetadata[] {\n const outputMetadata: OptionMetadata[] = [];\n\n if (!options || !options.length) return outputMetadata;\n\n for (const option of options) {\n const defaultValue = schemaDefaultValue(option.type);\n const aliases = option.aliases ?? [];\n\n outputMetadata.push({\n name: option.name,\n nameAsArg: transformOptionToArg(option.name),\n aliases,\n aliasesAsArgs: aliases.map(transformOptionToArg),\n placeholder: option.placeholder ?? \"\",\n description: option.description ?? schemaDescription(option.type) ?? \"\",\n optional: isOptionalSchema(option.type),\n example: option.example ?? \"\",\n defaultValue,\n defaultValueAsString: stringifyValue(defaultValue),\n type: option.type,\n });\n }\n\n return outputMetadata;\n}\n"],"mappings":"oHAAA,IAAAA,cAAA,CAAAC,OAAA,sCACA,IAAAC,MAAA,CAAAD,OAAA,gBACA,IAAAE,SAAA,CAAAF,OAAA,oBAKO,QAAS,CAAAG,kBAAkBA,CAACC,OAAiB,CAAoB,CACtE,KAAM,CAAAC,cAAgC,CAAG,EAAE,CAE3C,GAAI,CAACD,OAAO,EAAI,CAACA,OAAO,CAACE,MAAM,CAAE,MAAO,CAAAD,cAAc,CAEtD,IAAK,KAAM,CAAAE,MAAM,GAAI,CAAAH,OAAO,CAAE,CAC5B,KAAM,CAAAI,YAAY,CAAG,GAAAC,4BAAkB,EAACF,MAAM,CAACG,IAAI,CAAC,CACpD,KAAM,CAAAC,OAAO,CAAGJ,MAAM,CAACI,OAAO,EAAI,EAAE,CAEpCN,cAAc,CAACO,IAAI,CAAC,CAClBC,IAAI,CAAEN,MAAM,CAACM,IAAI,CACjBC,SAAS,CAAE,GAAAC,mCAAoB,EAACR,MAAM,CAACM,IAAI,CAAC,CAC5CF,OAAO,CACPK,aAAa,CAAEL,OAAO,CAACM,GAAG,CAACF,mCAAoB,CAAC,CAChDG,WAAW,CAAEX,MAAM,CAACW,WAAW,EAAI,EAAE,CACrCC,WAAW,CAAEZ,MAAM,CAACY,WAAW,EAAI,GAAAC,2BAAiB,EAACb,MAAM,CAACG,IAAI,CAAC,EAAI,EAAE,CACvEW,QAAQ,CAAE,GAAAC,0BAAgB,EAACf,MAAM,CAACG,IAAI,CAAC,CACvCa,OAAO,CAAEhB,MAAM,CAACgB,OAAO,EAAI,EAAE,CAC7Bf,YAAY,CACZgB,oBAAoB,CAAE,GAAAC,qBAAc,EAACjB,YAAY,CAAC,CAClDE,IAAI,CAAEH,MAAM,CAACG,IACf,CAAC,CAAC,CACJ,CAEA,MAAO,CAAAL,cAAc,CACvB","ignoreList":[]}
|
package/lib/commonjs/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.concat=concat;exports.generateOrdinalSuffix=generateOrdinalSuffix;exports.indent=indent;exports.ln=ln;exports.stringToBoolean=stringToBoolean;exports.stringifyValue=stringifyValue;function stringToBoolean(str){if(str.toLowerCase()==="true"){return true;}if(str.toLowerCase()==="false"){return false;}return str;}function generateOrdinalSuffix(index){if(index<0)return"";const suffixes=["th","st","nd","rd"];const lastDigit=index%10;const lastTwoDigits=index%100;const suffix=lastDigit===1&&lastTwoDigits!==11?suffixes[1]:lastDigit===2&&lastTwoDigits!==12?suffixes[2]:lastDigit===3&&lastTwoDigits!==13?suffixes[3]:suffixes[0];return`${index+1}${suffix}`;}function ln(count){return"\n".repeat(count);}function indent(count){return" ".repeat(count);}function concat(...messages){return messages.join(" ");}function stringifyValue(value){if(value instanceof Set){return"new Set(["+Array.from(value).map(stringifyValue).join(", ")+"])";}return JSON.stringify(value);}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.concat=concat;exports.generateOrdinalSuffix=generateOrdinalSuffix;exports.indent=indent;exports.insertAtEndOfFirstLine=insertAtEndOfFirstLine;exports.ln=ln;exports.stringToBoolean=stringToBoolean;exports.stringifyValue=stringifyValue;function stringToBoolean(str){if(str.toLowerCase()==="true"){return true;}if(str.toLowerCase()==="false"){return false;}return str;}function generateOrdinalSuffix(index){if(index<0)return"";const suffixes=["th","st","nd","rd"];const lastDigit=index%10;const lastTwoDigits=index%100;const suffix=lastDigit===1&&lastTwoDigits!==11?suffixes[1]:lastDigit===2&&lastTwoDigits!==12?suffixes[2]:lastDigit===3&&lastTwoDigits!==13?suffixes[3]:suffixes[0];return`${index+1}${suffix}`;}function ln(count){return"\n".repeat(count);}function indent(count){return" ".repeat(count);}function concat(...messages){return messages.join(" ");}function stringifyValue(value){if(value instanceof Set){return"new Set(["+Array.from(value).map(stringifyValue).join(", ")+"])";}return JSON.stringify(value);}function insertAtEndOfFirstLine(str,insert){const lines=str.split("\n");lines[0]+=" "+insert;return lines.join("\n");}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["stringToBoolean","str","toLowerCase","generateOrdinalSuffix","index","suffixes","lastDigit","lastTwoDigits","suffix","ln","count","repeat","indent","concat","messages","join","stringifyValue","value","Set","Array","from","map","JSON","stringify"],"sourceRoot":"../../src","sources":["utils.ts"],"sourcesContent":["/**\n * Converts a string to its corresponding boolean value if the string is \"true\" or \"false\" (case-insensitive).\n *\n * @param str - The input string to convert.\n * @returns `true` if the input is \"true\", `false` if the input is \"false\", or the original string otherwise.\n */\nexport function stringToBoolean(str: string): boolean | string {\n if (str.toLowerCase() === \"true\") {\n return true;\n }\n\n if (str.toLowerCase() === \"false\") {\n return false;\n }\n\n return str;\n}\n\n/**\n * Returns the ordinal representation of a given zero-based index.\n *\n * For example, passing `0` returns `\"1st\"`, `1` returns `\"2nd\"`, and so on.\n *\n * Handles special cases for numbers ending in 11, 12, or 13 (e.g., `10` returns `\"11th\"`).\n *\n * @param index - The zero-based index to convert to an ordinal string.\n * @returns The ordinal string representation (e.g., `\"1st\"`, `\"2nd\"`, `\"3rd\"`, `\"4th\"`, ...).\n */\nexport function generateOrdinalSuffix(index: number): string {\n if (index < 0) return \"\";\n\n const suffixes = [\"th\", \"st\", \"nd\", \"rd\"];\n const lastDigit = index % 10;\n const lastTwoDigits = index % 100;\n\n const suffix =\n lastDigit === 1 && lastTwoDigits !== 11\n ? suffixes[1]\n : lastDigit === 2 && lastTwoDigits !== 12\n ? suffixes[2]\n : lastDigit === 3 && lastTwoDigits !== 13\n ? suffixes[3]\n : suffixes[0];\n\n return `${index + 1}${suffix}`;\n}\n\n/** New line */\nexport function ln(count: number) {\n return \"\\n\".repeat(count);\n}\n\n/** Space */\nexport function indent(count: number) {\n return \" \".repeat(count);\n}\n\n/** Concat strings */\nexport function concat(...messages: string[]) {\n // messages = messages.filter(Boolean);\n return messages.join(\" \");\n}\n\nexport function stringifyValue(value: unknown): string {\n // Set\n if (value instanceof Set) {\n return \"new Set([\" + Array.from(value).map(stringifyValue).join(\", \") + \"])\";\n }\n\n // unknown\n return JSON.stringify(value);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["stringToBoolean","str","toLowerCase","generateOrdinalSuffix","index","suffixes","lastDigit","lastTwoDigits","suffix","ln","count","repeat","indent","concat","messages","join","stringifyValue","value","Set","Array","from","map","JSON","stringify","insertAtEndOfFirstLine","insert","lines","split"],"sourceRoot":"../../src","sources":["utils.ts"],"sourcesContent":["/**\n * Converts a string to its corresponding boolean value if the string is \"true\" or \"false\" (case-insensitive).\n *\n * @param str - The input string to convert.\n * @returns `true` if the input is \"true\", `false` if the input is \"false\", or the original string otherwise.\n */\nexport function stringToBoolean(str: string): boolean | string {\n if (str.toLowerCase() === \"true\") {\n return true;\n }\n\n if (str.toLowerCase() === \"false\") {\n return false;\n }\n\n return str;\n}\n\n/**\n * Returns the ordinal representation of a given zero-based index.\n *\n * For example, passing `0` returns `\"1st\"`, `1` returns `\"2nd\"`, and so on.\n *\n * Handles special cases for numbers ending in 11, 12, or 13 (e.g., `10` returns `\"11th\"`).\n *\n * @param index - The zero-based index to convert to an ordinal string.\n * @returns The ordinal string representation (e.g., `\"1st\"`, `\"2nd\"`, `\"3rd\"`, `\"4th\"`, ...).\n */\nexport function generateOrdinalSuffix(index: number): string {\n if (index < 0) return \"\";\n\n const suffixes = [\"th\", \"st\", \"nd\", \"rd\"];\n const lastDigit = index % 10;\n const lastTwoDigits = index % 100;\n\n const suffix =\n lastDigit === 1 && lastTwoDigits !== 11\n ? suffixes[1]\n : lastDigit === 2 && lastTwoDigits !== 12\n ? suffixes[2]\n : lastDigit === 3 && lastTwoDigits !== 13\n ? suffixes[3]\n : suffixes[0];\n\n return `${index + 1}${suffix}`;\n}\n\n/** New line */\nexport function ln(count: number) {\n return \"\\n\".repeat(count);\n}\n\n/** Space */\nexport function indent(count: number) {\n return \" \".repeat(count);\n}\n\n/** Concat strings */\nexport function concat(...messages: string[]) {\n // messages = messages.filter(Boolean);\n return messages.join(\" \");\n}\n\nexport function stringifyValue(value: unknown): string {\n // Set\n if (value instanceof Set) {\n return \"new Set([\" + Array.from(value).map(stringifyValue).join(\", \") + \"])\";\n }\n\n // unknown\n return JSON.stringify(value);\n}\n\n/** Insert text at the end of the first line */\nexport function insertAtEndOfFirstLine(str: string, insert: string) {\n const lines = str.split(\"\\n\");\n lines[0] += \" \" + insert;\n return lines.join(\"\\n\");\n}\n"],"mappings":"wTAMO,QAAS,CAAAA,eAAeA,CAACC,GAAW,CAAoB,CAC7D,GAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,GAAK,MAAM,CAAE,CAChC,MAAO,KAAI,CACb,CAEA,GAAID,GAAG,CAACC,WAAW,CAAC,CAAC,GAAK,OAAO,CAAE,CACjC,MAAO,MAAK,CACd,CAEA,MAAO,CAAAD,GAAG,CACZ,CAYO,QAAS,CAAAE,qBAAqBA,CAACC,KAAa,CAAU,CAC3D,GAAIA,KAAK,CAAG,CAAC,CAAE,MAAO,EAAE,CAExB,KAAM,CAAAC,QAAQ,CAAG,CAAC,IAAI,CAAE,IAAI,CAAE,IAAI,CAAE,IAAI,CAAC,CACzC,KAAM,CAAAC,SAAS,CAAGF,KAAK,CAAG,EAAE,CAC5B,KAAM,CAAAG,aAAa,CAAGH,KAAK,CAAG,GAAG,CAEjC,KAAM,CAAAI,MAAM,CACVF,SAAS,GAAK,CAAC,EAAIC,aAAa,GAAK,EAAE,CACnCF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(argsMetadata,c,longest){if(!argsMetadata.length)return"";let msg=c.title(" ARGUMENTS")+ln(1);for(const metadata of argsMetadata){const defaultStr=typeof metadata.defaultValue!=="undefined"?`(default: ${metadata.defaultValueAsString})`:"";const spacing=longest+2-metadata.name.length;const normalizeDesc=metadata.description.replace(/\n/g,"\n"+indent(longest+6)+c.punctuation("└"));msg+=concat(indent(2)+c.argument(metadata.name),indent(spacing),c.description(normalizeDesc),
|
|
1
|
+
import{concat,indent,insertAtEndOfFirstLine,ln}from"../utils.js";export function formatHelpMsgArguments(argsMetadata,c,longest){if(!argsMetadata.length)return"";let msg=c.title(" ARGUMENTS")+ln(1);for(const metadata of argsMetadata){const defaultStr=typeof metadata.defaultValue!=="undefined"?`(default: ${metadata.defaultValueAsString})`:"";const spacing=longest+2-metadata.name.length;const normalizeDesc=metadata.description.replace(/\n/g,"\n"+indent(longest+6)+c.punctuation("└"));const defaultOrOptional=defaultStr?c.default(defaultStr):metadata.optional?c.optional("(optional)"):"";msg+=concat(indent(2)+c.argument(metadata.name),indent(spacing),insertAtEndOfFirstLine(c.description(normalizeDesc),defaultOrOptional),ln(1));if(metadata.example){const normalizeExample=metadata.example.replace(/\n/g,"\n"+indent(longest+16));msg+=concat(indent(longest+5),c.punctuation("└")+c.exampleTitle("Example:"),c.example(normalizeExample)+ln(1));}}msg+=ln(1);return msg;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["concat","indent","ln","formatHelpMsgArguments","argsMetadata","c","longest","length","msg","title","metadata","defaultStr","defaultValue","defaultValueAsString","spacing","name","normalizeDesc","description","replace","punctuation","
|
|
1
|
+
{"version":3,"names":["concat","indent","insertAtEndOfFirstLine","ln","formatHelpMsgArguments","argsMetadata","c","longest","length","msg","title","metadata","defaultStr","defaultValue","defaultValueAsString","spacing","name","normalizeDesc","description","replace","punctuation","defaultOrOptional","default","optional","argument","example","normalizeExample","exampleTitle"],"sourceRoot":"../../../src/help-message","sources":["format-arguments.ts"],"sourcesContent":["import { concat, indent, insertAtEndOfFirstLine, ln } from \"../utils.js\";\n\nimport type { ArgumentMetadata } from \"../metadata/metadata-types.js\";\nimport type { HelpMsgStyle } from \"../types.js\";\n\nexport function formatHelpMsgArguments(argsMetadata: ArgumentMetadata[], c: HelpMsgStyle, longest: number): string {\n if (!argsMetadata.length) return \"\";\n\n let msg = c.title(\" ARGUMENTS\") + ln(1);\n\n for (const metadata of argsMetadata) {\n const defaultStr =\n typeof metadata.defaultValue !== \"undefined\" ? `(default: ${metadata.defaultValueAsString})` : \"\";\n\n const spacing = longest + 2 - metadata.name.length;\n const normalizeDesc = metadata.description.replace(/\\n/g, \"\\n\" + indent(longest + 6) + c.punctuation(\"└\"));\n const defaultOrOptional = defaultStr ? c.default(defaultStr) : metadata.optional ? c.optional(\"(optional)\") : \"\";\n\n msg += concat(\n indent(2) + c.argument(metadata.name),\n indent(spacing),\n insertAtEndOfFirstLine(c.description(normalizeDesc), defaultOrOptional),\n ln(1),\n );\n\n if (metadata.example) {\n const normalizeExample = metadata.example.replace(/\\n/g, \"\\n\" + indent(longest + 16));\n msg += concat(\n indent(longest + 5),\n c.punctuation(\"└\") + c.exampleTitle(\"Example:\"),\n c.example(normalizeExample) + ln(1),\n );\n }\n }\n\n msg += ln(1);\n\n return msg;\n}\n"],"mappings":"AAAA,OAASA,MAAM,CAAEC,MAAM,CAAEC,sBAAsB,CAAEC,EAAE,KAAQ,aAAa,CAKxE,MAAO,SAAS,CAAAC,sBAAsBA,CAACC,YAAgC,CAAEC,CAAe,CAAEC,OAAe,CAAU,CACjH,GAAI,CAACF,YAAY,CAACG,MAAM,CAAE,MAAO,EAAE,CAEnC,GAAI,CAAAC,GAAG,CAAGH,CAAC,CAACI,KAAK,CAAC,YAAY,CAAC,CAAGP,EAAE,CAAC,CAAC,CAAC,CAEvC,IAAK,KAAM,CAAAQ,QAAQ,GAAI,CAAAN,YAAY,CAAE,CACnC,KAAM,CAAAO,UAAU,CACd,MAAO,CAAAD,QAAQ,CAACE,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EAAE,CAAC,CAAC,CAAC,CAEZ,MAAO,CAAAM,GAAG,CACZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{concat,indent,ln}from"../utils.js";export function formatHelpMsgOptions(optionsMetadata,c,longest){if(!optionsMetadata.length)return"";let msg=c.title(" OPTIONS")+ln(1);for(const metadata of optionsMetadata){const names=metadata.aliasesAsArgs.concat([metadata.nameAsArg]);const normalizeDesc=metadata.description.replace(/\n/g,"\n"+indent(longest+
|
|
1
|
+
import{concat,indent,insertAtEndOfFirstLine,ln}from"../utils.js";export function formatHelpMsgOptions(optionsMetadata,c,longest){if(!optionsMetadata.length)return"";let msg=c.title(" OPTIONS")+ln(1);for(const metadata of optionsMetadata){const names=metadata.aliasesAsArgs.concat([metadata.nameAsArg]);const normalizeDesc=metadata.description.replace(/\n/g,"\n"+indent(longest+6)+c.punctuation("└"));const defaultStr=typeof metadata.defaultValue!=="undefined"?`(default: ${metadata.defaultValueAsString})`:"";const optLength=names.join(", ").length+metadata.placeholder.length;const spacing=longest+1-optLength;const coloredNames=names.map(name=>c.option(name)).join(c.punctuation(", "));const defaultOrOptional=defaultStr?c.default(defaultStr):metadata.optional?c.optional("(optional)"):"";msg+=concat(indent(2)+coloredNames,c.placeholder(metadata.placeholder),indent(spacing),insertAtEndOfFirstLine(c.description(normalizeDesc),defaultOrOptional),ln(1));if(metadata.example){const normalizeExample=metadata.example.replace(/\n/g,"\n"+indent(longest+16));msg+=concat(indent(longest+6)+c.punctuation("└")+c.exampleTitle("Example:"),c.example(normalizeExample)+ln(1));}}msg+=ln(1);return msg;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["concat","indent","ln","formatHelpMsgOptions","optionsMetadata","c","longest","length","msg","title","metadata","names","aliasesAsArgs","nameAsArg","normalizeDesc","description","replace","punctuation","defaultStr","defaultValue","defaultValueAsString","optLength","join","placeholder","spacing","coloredNames","map","name","option","default","optional","example","normalizeExample","exampleTitle"],"sourceRoot":"../../../src/help-message","sources":["format-options.ts"],"sourcesContent":["import { concat, indent, ln } from \"../utils.js\";\n\nimport type { OptionMetadata } from \"../metadata/metadata-types.js\";\nimport type { HelpMsgStyle } from \"../types.js\";\n\nexport function formatHelpMsgOptions(optionsMetadata: OptionMetadata[], c: HelpMsgStyle, longest: number): string {\n if (!optionsMetadata.length) return \"\";\n\n let msg = c.title(\" OPTIONS\") + ln(1);\n\n for (const metadata of optionsMetadata) {\n const names = metadata.aliasesAsArgs.concat([metadata.nameAsArg]);\n const normalizeDesc = metadata.description.replace(/\\n/g, \"\\n\" + indent(longest +
|
|
1
|
+
{"version":3,"names":["concat","indent","insertAtEndOfFirstLine","ln","formatHelpMsgOptions","optionsMetadata","c","longest","length","msg","title","metadata","names","aliasesAsArgs","nameAsArg","normalizeDesc","description","replace","punctuation","defaultStr","defaultValue","defaultValueAsString","optLength","join","placeholder","spacing","coloredNames","map","name","option","defaultOrOptional","default","optional","example","normalizeExample","exampleTitle"],"sourceRoot":"../../../src/help-message","sources":["format-options.ts"],"sourcesContent":["import { concat, indent, insertAtEndOfFirstLine, ln } from \"../utils.js\";\n\nimport type { OptionMetadata } from \"../metadata/metadata-types.js\";\nimport type { HelpMsgStyle } from \"../types.js\";\n\nexport function formatHelpMsgOptions(optionsMetadata: OptionMetadata[], c: HelpMsgStyle, longest: number): string {\n if (!optionsMetadata.length) return \"\";\n\n let msg = c.title(\" OPTIONS\") + ln(1);\n\n for (const metadata of optionsMetadata) {\n const names = metadata.aliasesAsArgs.concat([metadata.nameAsArg]);\n const normalizeDesc = metadata.description.replace(/\\n/g, \"\\n\" + indent(longest + 6) + c.punctuation(\"└\"));\n const defaultStr =\n typeof metadata.defaultValue !== \"undefined\" ? `(default: ${metadata.defaultValueAsString})` : \"\";\n\n const optLength = names.join(\", \").length + metadata.placeholder.length;\n const spacing = longest + 1 - optLength;\n\n const coloredNames = names.map(name => c.option(name)).join(c.punctuation(\", \"));\n\n const defaultOrOptional = defaultStr ? c.default(defaultStr) : metadata.optional ? c.optional(\"(optional)\") : \"\";\n\n msg += concat(\n indent(2) + coloredNames,\n c.placeholder(metadata.placeholder),\n indent(spacing),\n insertAtEndOfFirstLine(c.description(normalizeDesc), defaultOrOptional),\n ln(1),\n );\n\n if (metadata.example) {\n const normalizeExample = metadata.example.replace(/\\n/g, \"\\n\" + indent(longest + 16));\n msg += concat(\n indent(longest + 6) + c.punctuation(\"└\") + c.exampleTitle(\"Example:\"),\n c.example(normalizeExample) + ln(1),\n );\n }\n }\n\n msg += ln(1);\n\n return msg;\n}\n"],"mappings":"AAAA,OAASA,MAAM,CAAEC,MAAM,CAAEC,sBAAsB,CAAEC,EAAE,KAAQ,aAAa,CAKxE,MAAO,SAAS,CAAAC,oBAAoBA,CAACC,eAAiC,CAAEC,CAAe,CAAEC,OAAe,CAAU,CAChH,GAAI,CAACF,eAAe,CAACG,MAAM,CAAE,MAAO,EAAE,CAEtC,GAAI,CAAAC,GAAG,CAAGH,CAAC,CAACI,KAAK,CAAC,UAAU,CAAC,CAAGP,EAAE,CAAC,CAAC,CAAC,CAErC,IAAK,KAAM,CAAAQ,QAAQ,GAAI,CAAAN,eAAe,CAAE,CACtC,KAAM,CAAAO,KAAK,CAAGD,QAAQ,CAACE,aAAa,CAACb,MAAM,CAAC,CAACW,QAAQ,CAACG,SAAS,CAAC,CAAC,CACjE,KAAM,CAAAC,aAAa,CAAGJ,QAAQ,CAACK,WAAW,CAACC,OAAO,CAAC,KAAK,CAAE,IAAI,CAAGhB,MAAM,CAACM,OAAO,CAAG,CAAC,CAAC,CAAGD,CAAC,CAACY,WAAW,CAAC,GAAG,CAAC,CAAC,CAC1G,KAAM,CAAAC,UAAU,CACd,MAAO,CAAAR,QAAQ,CAACS,YAAY,GAAK,WAAW,CAAG,aAAaT,QAAQ,CAACU,oBAAoB,GAAG,CAAG,EAAE,CAEnG,KAAM,CAAAC,SAAS,CAAGV,KAAK,CAACW,IAAI,CAAC,IAAI,CAAC,CAACf,MAAM,CAAGG,QAA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AM,GAAG,CACZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{stringifyValue}from"
|
|
1
|
+
import{stringifyValue}from"../utils.js";import{isOptionalSchema,schemaDefaultValue,schemaDescription}from"../zod-utils.js";export function getArgumentsMetadata(args){const outputMetadata=[];for(const arg of args){const defaultValue=schemaDefaultValue(arg.type);outputMetadata.push({name:arg.name,description:arg.description??schemaDescription(arg.type)??"",defaultValue,defaultValueAsString:stringifyValue(defaultValue),optional:isOptionalSchema(arg.type),example:arg.example??"",type:arg.type});}return outputMetadata;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["stringifyValue","isOptionalSchema","schemaDefaultValue","schemaDescription","getArgumentsMetadata","args","outputMetadata","arg","defaultValue","type","push","name","description","defaultValueAsString","optional","example"],"sourceRoot":"../../../src/metadata","sources":["get-arguments-metadata.ts"],"sourcesContent":["import { stringifyValue } from \"
|
|
1
|
+
{"version":3,"names":["stringifyValue","isOptionalSchema","schemaDefaultValue","schemaDescription","getArgumentsMetadata","args","outputMetadata","arg","defaultValue","type","push","name","description","defaultValueAsString","optional","example"],"sourceRoot":"../../../src/metadata","sources":["get-arguments-metadata.ts"],"sourcesContent":["import { stringifyValue } from \"../utils.js\";\nimport { isOptionalSchema, schemaDefaultValue, schemaDescription } from \"../zod-utils.js\";\n\nimport type { Argument } from \"../types.js\";\nimport type { ArgumentMetadata } from \"./metadata-types.js\";\n\nexport function getArgumentsMetadata(args: Argument[]): ArgumentMetadata[] {\n const outputMetadata: ArgumentMetadata[] = [];\n\n for (const arg of args) {\n const defaultValue = schemaDefaultValue(arg.type);\n\n outputMetadata.push({\n name: arg.name,\n description: arg.description ?? schemaDescription(arg.type) ?? \"\",\n defaultValue,\n defaultValueAsString: stringifyValue(defaultValue),\n optional: isOptionalSchema(arg.type),\n example: arg.example ?? \"\",\n type: arg.type,\n });\n }\n\n return outputMetadata;\n}\n"],"mappings":"AAAA,OAASA,cAAc,KAAQ,aAAa,CAC5C,OAASC,gBAAgB,CAAEC,kBAAkB,CAAEC,iBAAiB,KAAQ,iBAAiB,CAKzF,MAAO,SAAS,CAAAC,oBAAoBA,CAACC,IAAgB,CAAsB,CACzE,KAAM,CAAAC,cAAkC,CAAG,EAAE,CAE7C,IAAK,KAAM,CAAAC,GAAG,GAAI,CAAAF,IAAI,CAAE,CACtB,KAAM,CAAAG,YAAY,CAAGN,kBAAkB,CAACK,GAAG,CAACE,IAAI,CAAC,CAEjDH,cAAc,CAACI,IAAI,CAAC,CAClBC,IAAI,CAAEJ,GAAG,CAACI,IAAI,CACdC,WAAW,CAAEL,GAAG,CAACK,WAAW,EAAIT,iBAAiB,CAACI,GAAG,CAACE,IAAI,CAAC,EAAI,EAAE,CACjED,YAAY,CACZK,oBAAoB,CAAEb,cAAc,CAACQ,YAAY,CAAC,CAClDM,QAAQ,CAAEb,gBAAgB,CAACM,GAAG,CAACE,IAAI,CAAC,CACpCM,OAAO,CAAER,GAAG,CAACQ,OAAO,EAAI,EAAE,CAC1BN,IAAI,CAAEF,GAAG,CAACE,IACZ,CAAC,CAAC,CACJ,CAEA,MAAO,CAAAH,cAAc,CACvB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{transformOptionToArg}from"../parser/parse/parser-helpers.js";import{stringifyValue}from"../utils.js";import{isOptionalSchema,schemaDefaultValue,schemaDescription}from"../zod-utils.js";export function getOptionsMetadata(options){const outputMetadata=[];if(!options||!options.length)return outputMetadata;for(const option of options){const defaultValue=schemaDefaultValue(option.type);const aliases=option.aliases??[];outputMetadata.push({name:option.name,nameAsArg:transformOptionToArg(option.name),aliases,aliasesAsArgs:aliases.map(transformOptionToArg),placeholder:option.placeholder??"",description:option.description??schemaDescription(option.type)??"",optional:isOptionalSchema(option.type),example:option.example??"",defaultValue,defaultValueAsString:stringifyValue(defaultValue),type:option.type});}return outputMetadata;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["transformOptionToArg","stringifyValue","isOptionalSchema","schemaDefaultValue","schemaDescription","getOptionsMetadata","options","outputMetadata","length","option","defaultValue","type","aliases","push","name","nameAsArg","aliasesAsArgs","map","placeholder","description","optional","example","defaultValueAsString"],"sourceRoot":"../../../src/metadata","sources":["get-options-metadata.ts"],"sourcesContent":["import { transformOptionToArg } from \"../parser/parse/parser-helpers.js\";\nimport { stringifyValue } from \"../utils.js\";\nimport { isOptionalSchema, schemaDefaultValue, schemaDescription } from \"../zod-utils.js\";\n\nimport type { Option } from \"../types.js\";\nimport type { OptionMetadata } from \"./metadata-types.js\";\n\nexport function getOptionsMetadata(options: Option[]): OptionMetadata[] {\n const outputMetadata: OptionMetadata[] = [];\n\n if (!options || !options.length) return outputMetadata;\n\n for (const option of options) {\n const defaultValue = schemaDefaultValue(option.type);\n const aliases = option.aliases ?? [];\n\n outputMetadata.push({\n name: option.name,\n nameAsArg: transformOptionToArg(option.name),\n aliases,\n aliasesAsArgs: aliases.map(transformOptionToArg),\n placeholder: option.placeholder ?? \"\",\n description: option.description ?? schemaDescription(option.type) ?? \"\",\n optional: isOptionalSchema(option.type),\n example: option.example ?? \"\",\n defaultValue,\n defaultValueAsString: stringifyValue(defaultValue),\n type: option.type,\n });\n }\n\n return outputMetadata;\n}\n"],"mappings":"AAAA,OAASA,oBAAoB,KAAQ,mCAAmC,CACxE,OAASC,cAAc,KAAQ,aAAa,CAC5C,OAASC,gBAAgB,CAAEC,kBAAkB,CAAEC,iBAAiB,KAAQ,iBAAiB,CAKzF,MAAO,SAAS,CAAAC,kBAAkBA,CAACC,OAAiB,CAAoB,CACtE,KAAM,CAAAC,cAAgC,CAAG,EAAE,CAE3C,GAAI,CAACD,OAAO,EAAI,CAACA,OAAO,CAACE,MAAM,CAAE,MAAO,CAAAD,cAAc,CAEtD,IAAK,KAAM,CAAAE,MAAM,GAAI,CAAAH,OAAO,CAAE,CAC5B,KAAM,CAAAI,YAAY,CAAGP,kBAAkB,CAACM,MAAM,CAACE,IAAI,CAAC,CACpD,KAAM,CAAAC,OAAO,CAAGH,MAAM,CAACG,OAAO,EAAI,EAAE,CAEpCL,cAAc,CAACM,IAAI,CAAC,CAClBC,IAAI,CAAEL,MAAM,CAACK,IAAI,CACjBC,SAAS,CAAEf,oBAAoB,CAACS,MAAM,CAACK,IAAI,CAAC,CAC5CF,OAAO,CACPI,aAAa,CAAEJ,OAAO,CAACK,GAAG,CAACjB,oBAAoB,CAAC,CAChDkB,WAAW,CAAET,MAAM,CAACS,WAAW,EAAI,EAAE,CACrCC,WAAW,CAAEV,MAAM,CAACU,WAAW,EAAIf,iBAAiB,CAACK,MAAM,CAACE,IAAI,CAAC,EAAI,EAAE,CACvES,QAAQ,CAAElB,gBAAgB,CAACO,MAAM,CAACE,IAAI,CAAC,CACvCU,OAAO,CAAEZ,MAAM,CAACY,OAAO,EAAI,EAAE,CAC7BX,YAAY,CACZY,oBAAoB,CAAErB,cAAc,CAACS,YAAY,CAAC,CAClDC,IAAI,CAAEF,MAAM,CAACE,IACf,CAAC,CAAC,CACJ,CAEA,MAAO,CAAAJ,cAAc,CACvB","ignoreList":[]}
|
package/lib/module/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function stringToBoolean(str){if(str.toLowerCase()==="true"){return true;}if(str.toLowerCase()==="false"){return false;}return str;}export function generateOrdinalSuffix(index){if(index<0)return"";const suffixes=["th","st","nd","rd"];const lastDigit=index%10;const lastTwoDigits=index%100;const suffix=lastDigit===1&&lastTwoDigits!==11?suffixes[1]:lastDigit===2&&lastTwoDigits!==12?suffixes[2]:lastDigit===3&&lastTwoDigits!==13?suffixes[3]:suffixes[0];return`${index+1}${suffix}`;}export function ln(count){return"\n".repeat(count);}export function indent(count){return" ".repeat(count);}export function concat(...messages){return messages.join(" ");}export function stringifyValue(value){if(value instanceof Set){return"new Set(["+Array.from(value).map(stringifyValue).join(", ")+"])";}return JSON.stringify(value);}
|
|
1
|
+
export function stringToBoolean(str){if(str.toLowerCase()==="true"){return true;}if(str.toLowerCase()==="false"){return false;}return str;}export function generateOrdinalSuffix(index){if(index<0)return"";const suffixes=["th","st","nd","rd"];const lastDigit=index%10;const lastTwoDigits=index%100;const suffix=lastDigit===1&&lastTwoDigits!==11?suffixes[1]:lastDigit===2&&lastTwoDigits!==12?suffixes[2]:lastDigit===3&&lastTwoDigits!==13?suffixes[3]:suffixes[0];return`${index+1}${suffix}`;}export function ln(count){return"\n".repeat(count);}export function indent(count){return" ".repeat(count);}export function concat(...messages){return messages.join(" ");}export function stringifyValue(value){if(value instanceof Set){return"new Set(["+Array.from(value).map(stringifyValue).join(", ")+"])";}return JSON.stringify(value);}export function insertAtEndOfFirstLine(str,insert){const lines=str.split("\n");lines[0]+=" "+insert;return lines.join("\n");}
|
package/lib/module/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["stringToBoolean","str","toLowerCase","generateOrdinalSuffix","index","suffixes","lastDigit","lastTwoDigits","suffix","ln","count","repeat","indent","concat","messages","join","stringifyValue","value","Set","Array","from","map","JSON","stringify"],"sourceRoot":"../../src","sources":["utils.ts"],"sourcesContent":["/**\n * Converts a string to its corresponding boolean value if the string is \"true\" or \"false\" (case-insensitive).\n *\n * @param str - The input string to convert.\n * @returns `true` if the input is \"true\", `false` if the input is \"false\", or the original string otherwise.\n */\nexport function stringToBoolean(str: string): boolean | string {\n if (str.toLowerCase() === \"true\") {\n return true;\n }\n\n if (str.toLowerCase() === \"false\") {\n return false;\n }\n\n return str;\n}\n\n/**\n * Returns the ordinal representation of a given zero-based index.\n *\n * For example, passing `0` returns `\"1st\"`, `1` returns `\"2nd\"`, and so on.\n *\n * Handles special cases for numbers ending in 11, 12, or 13 (e.g., `10` returns `\"11th\"`).\n *\n * @param index - The zero-based index to convert to an ordinal string.\n * @returns The ordinal string representation (e.g., `\"1st\"`, `\"2nd\"`, `\"3rd\"`, `\"4th\"`, ...).\n */\nexport function generateOrdinalSuffix(index: number): string {\n if (index < 0) return \"\";\n\n const suffixes = [\"th\", \"st\", \"nd\", \"rd\"];\n const lastDigit = index % 10;\n const lastTwoDigits = index % 100;\n\n const suffix =\n lastDigit === 1 && lastTwoDigits !== 11\n ? suffixes[1]\n : lastDigit === 2 && lastTwoDigits !== 12\n ? suffixes[2]\n : lastDigit === 3 && lastTwoDigits !== 13\n ? suffixes[3]\n : suffixes[0];\n\n return `${index + 1}${suffix}`;\n}\n\n/** New line */\nexport function ln(count: number) {\n return \"\\n\".repeat(count);\n}\n\n/** Space */\nexport function indent(count: number) {\n return \" \".repeat(count);\n}\n\n/** Concat strings */\nexport function concat(...messages: string[]) {\n // messages = messages.filter(Boolean);\n return messages.join(\" \");\n}\n\nexport function stringifyValue(value: unknown): string {\n // Set\n if (value instanceof Set) {\n return \"new Set([\" + Array.from(value).map(stringifyValue).join(\", \") + \"])\";\n }\n\n // unknown\n return JSON.stringify(value);\n}\n"],"mappings":"AAMA,MAAO,SAAS,CAAAA,eAAeA,CAACC,GAAW,CAAoB,CAC7D,GAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,GAAK,MAAM,CAAE,CAChC,MAAO,KAAI,CACb,CAEA,GAAID,GAAG,CAACC,WAAW,CAAC,CAAC,GAAK,OAAO,CAAE,CACjC,MAAO,MAAK,CACd,CAEA,MAAO,CAAAD,GAAG,CACZ,CAYA,MAAO,SAAS,CAAAE,qBAAqBA,CAACC,KAAa,CAAU,CAC3D,GAAIA,KAAK,CAAG,CAAC,CAAE,MAAO,EAAE,CAExB,KAAM,CAAAC,QAAQ,CAAG,CAAC,IAAI,CAAE,IAAI,CAAE,IAAI,CAAE,IAAI,CAAC,CACzC,KAAM,CAAAC,SAAS,CAAGF,KAAK,CAAG,EAAE,CAC5B,KAAM,CAAAG,aAAa,CAAGH,KAAK,CAAG,GAAG,CAEjC,KAAM,CAAAI,MAAM,CACVF,SAAS,GAAK,CAAC,EAAIC,aAAa,GAAK,EAAE,CACnCF,QAAQ,CAAC,CAAC,CAAC,CACXC,SAAS,GAAK,CAAC,EAAIC,aAAa,GAAK,EAAE,CACrCF,QAAQ,CAAC,CAAC,CAAC,CACXC,SAAS,GAAK,CAAC,EAAIC,aAAa,GAAK,EAAE,CACrCF,QAAQ,CAAC,CAAC,CAAC,CACXA,QAAQ,CAAC,CAAC,CAAC,CAErB,MAAO,GAAGD,KAAK,CAAG,CAAC,GAAGI,MAAM,EAAE,CAChC,CAGA,MAAO,SAAS,CAAAC,EAAEA,CAACC,KAAa,CAAE,CAChC,MAAO,IAAI,CAACC,MAAM,CAACD,KAAK,CAAC,CAC3B,CAGA,MAAO,SAAS,CAAAE,MAAMA,CAACF,KAAa,CAAE,CACpC,MAAO,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,CAC1B,CAGA,MAAO,SAAS,CAAAG,MAAMA,CAAC,GAAGC,QAAkB,CAAE,CAE5C,MAAO,CAAAA,QAAQ,CAACC,IAAI,CAAC,GAAG,CAAC,CAC3B,CAEA,MAAO,SAAS,CAAAC,cAAcA,CAACC,KAAc,CAAU,CAErD,GAAIA,KAAK,WAAY,CAAAC,GAAG,CAAE,CACxB,MAAO,WAAW,CAAGC,KAAK,CAACC,IAAI,CAACH,KAAK,CAAC,CAACI,GAAG,CAACL,cAAc,CAAC,CAACD,IAAI,CAAC,IAAI,CAAC,CAAG,IAAI,CAC9E,CAGA,MAAO,CAAAO,IAAI,CAACC,SAAS,CAACN,KAAK,CAAC,CAC9B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["stringToBoolean","str","toLowerCase","generateOrdinalSuffix","index","suffixes","lastDigit","lastTwoDigits","suffix","ln","count","repeat","indent","concat","messages","join","stringifyValue","value","Set","Array","from","map","JSON","stringify","insertAtEndOfFirstLine","insert","lines","split"],"sourceRoot":"../../src","sources":["utils.ts"],"sourcesContent":["/**\n * Converts a string to its corresponding boolean value if the string is \"true\" or \"false\" (case-insensitive).\n *\n * @param str - The input string to convert.\n * @returns `true` if the input is \"true\", `false` if the input is \"false\", or the original string otherwise.\n */\nexport function stringToBoolean(str: string): boolean | string {\n if (str.toLowerCase() === \"true\") {\n return true;\n }\n\n if (str.toLowerCase() === \"false\") {\n return false;\n }\n\n return str;\n}\n\n/**\n * Returns the ordinal representation of a given zero-based index.\n *\n * For example, passing `0` returns `\"1st\"`, `1` returns `\"2nd\"`, and so on.\n *\n * Handles special cases for numbers ending in 11, 12, or 13 (e.g., `10` returns `\"11th\"`).\n *\n * @param index - The zero-based index to convert to an ordinal string.\n * @returns The ordinal string representation (e.g., `\"1st\"`, `\"2nd\"`, `\"3rd\"`, `\"4th\"`, ...).\n */\nexport function generateOrdinalSuffix(index: number): string {\n if (index < 0) return \"\";\n\n const suffixes = [\"th\", \"st\", \"nd\", \"rd\"];\n const lastDigit = index % 10;\n const lastTwoDigits = index % 100;\n\n const suffix =\n lastDigit === 1 && lastTwoDigits !== 11\n ? suffixes[1]\n : lastDigit === 2 && lastTwoDigits !== 12\n ? suffixes[2]\n : lastDigit === 3 && lastTwoDigits !== 13\n ? suffixes[3]\n : suffixes[0];\n\n return `${index + 1}${suffix}`;\n}\n\n/** New line */\nexport function ln(count: number) {\n return \"\\n\".repeat(count);\n}\n\n/** Space */\nexport function indent(count: number) {\n return \" \".repeat(count);\n}\n\n/** Concat strings */\nexport function concat(...messages: string[]) {\n // messages = messages.filter(Boolean);\n return messages.join(\" \");\n}\n\nexport function stringifyValue(value: unknown): string {\n // Set\n if (value instanceof Set) {\n return \"new Set([\" + Array.from(value).map(stringifyValue).join(\", \") + \"])\";\n }\n\n // unknown\n return JSON.stringify(value);\n}\n\n/** Insert text at the end of the first line */\nexport function insertAtEndOfFirstLine(str: string, insert: string) {\n const lines = str.split(\"\\n\");\n lines[0] += \" \" + insert;\n return lines.join(\"\\n\");\n}\n"],"mappings":"AAMA,MAAO,SAAS,CAAAA,eAAeA,CAACC,GAAW,CAAoB,CAC7D,GAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,GAAK,MAAM,CAAE,CAChC,MAAO,KAAI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C,KAAK,CAACC,IAAI,CAACH,KAAK,CAAC,CAACI,GAAG,CAACL,cAAc,CAAC,CAACD,IAAI,CAAC,IAAI,CAAC,CAAG,IAAI,CAC9E,CAGA,MAAO,CAAAO,IAAI,CAACC,SAAS,CAACN,KAAK,CAAC,CAC9B,CAGA,MAAO,SAAS,CAAAO,sBAAsBA,CAACvB,GAAW,CAAEwB,MAAc,CAAE,CAClE,KAAM,CAAAC,KAAK,CAAGzB,GAAG,CAAC0B,KAAK,CAAC,IAAI,CAAC,CAC7BD,KAAK,CAAC,CAAC,CAAC,EAAI,GAAG,CAAGD,MAAM,CACxB,MAAO,CAAAC,KAAK,CAACX,IAAI,CAAC,IAAI,CAAC,CACzB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-arguments.d.ts","sourceRoot":"","sources":["../../../src/help-message/format-arguments.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"format-arguments.d.ts","sourceRoot":"","sources":["../../../src/help-message/format-arguments.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAiCjH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-options.d.ts","sourceRoot":"","sources":["../../../src/help-message/format-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,cAAc,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"format-options.d.ts","sourceRoot":"","sources":["../../../src/help-message/format-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,cAAc,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAsChH"}
|
|
@@ -23,4 +23,6 @@ export declare function indent(count: number): string;
|
|
|
23
23
|
/** Concat strings */
|
|
24
24
|
export declare function concat(...messages: string[]): string;
|
|
25
25
|
export declare function stringifyValue(value: unknown): string;
|
|
26
|
+
/** Insert text at the end of the first line */
|
|
27
|
+
export declare function insertAtEndOfFirstLine(str: string, insert: string): string;
|
|
26
28
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAU7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiB3D;AAED,eAAe;AACf,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,UAE/B;AAED,YAAY;AACZ,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,UAEnC;AAED,qBAAqB;AACrB,wBAAgB,MAAM,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,UAG3C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQrD"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAU7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiB3D;AAED,eAAe;AACf,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,UAE/B;AAED,YAAY;AACZ,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,UAEnC;AAED,qBAAqB;AACrB,wBAAgB,MAAM,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,UAG3C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQrD;AAED,+CAA+C;AAC/C,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAIjE"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { concat, indent, ln } from "../utils.js";
|
|
1
|
+
import { concat, indent, insertAtEndOfFirstLine, ln } from "../utils.js";
|
|
2
2
|
|
|
3
3
|
import type { ArgumentMetadata } from "../metadata/metadata-types.js";
|
|
4
4
|
import type { HelpMsgStyle } from "../types.js";
|
|
@@ -14,12 +14,13 @@ export function formatHelpMsgArguments(argsMetadata: ArgumentMetadata[], c: Help
|
|
|
14
14
|
|
|
15
15
|
const spacing = longest + 2 - metadata.name.length;
|
|
16
16
|
const normalizeDesc = metadata.description.replace(/\n/g, "\n" + indent(longest + 6) + c.punctuation("└"));
|
|
17
|
+
const defaultOrOptional = defaultStr ? c.default(defaultStr) : metadata.optional ? c.optional("(optional)") : "";
|
|
17
18
|
|
|
18
19
|
msg += concat(
|
|
19
20
|
indent(2) + c.argument(metadata.name),
|
|
20
21
|
indent(spacing),
|
|
21
|
-
c.description(normalizeDesc),
|
|
22
|
-
|
|
22
|
+
insertAtEndOfFirstLine(c.description(normalizeDesc), defaultOrOptional),
|
|
23
|
+
ln(1),
|
|
23
24
|
);
|
|
24
25
|
|
|
25
26
|
if (metadata.example) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { concat, indent, ln } from "../utils.js";
|
|
1
|
+
import { concat, indent, insertAtEndOfFirstLine, ln } from "../utils.js";
|
|
2
2
|
|
|
3
3
|
import type { OptionMetadata } from "../metadata/metadata-types.js";
|
|
4
4
|
import type { HelpMsgStyle } from "../types.js";
|
|
@@ -10,7 +10,7 @@ export function formatHelpMsgOptions(optionsMetadata: OptionMetadata[], c: HelpM
|
|
|
10
10
|
|
|
11
11
|
for (const metadata of optionsMetadata) {
|
|
12
12
|
const names = metadata.aliasesAsArgs.concat([metadata.nameAsArg]);
|
|
13
|
-
const normalizeDesc = metadata.description.replace(/\n/g, "\n" + indent(longest +
|
|
13
|
+
const normalizeDesc = metadata.description.replace(/\n/g, "\n" + indent(longest + 6) + c.punctuation("└"));
|
|
14
14
|
const defaultStr =
|
|
15
15
|
typeof metadata.defaultValue !== "undefined" ? `(default: ${metadata.defaultValueAsString})` : "";
|
|
16
16
|
|
|
@@ -19,16 +19,18 @@ export function formatHelpMsgOptions(optionsMetadata: OptionMetadata[], c: HelpM
|
|
|
19
19
|
|
|
20
20
|
const coloredNames = names.map(name => c.option(name)).join(c.punctuation(", "));
|
|
21
21
|
|
|
22
|
+
const defaultOrOptional = defaultStr ? c.default(defaultStr) : metadata.optional ? c.optional("(optional)") : "";
|
|
23
|
+
|
|
22
24
|
msg += concat(
|
|
23
25
|
indent(2) + coloredNames,
|
|
24
26
|
c.placeholder(metadata.placeholder),
|
|
25
27
|
indent(spacing),
|
|
26
|
-
c.description(normalizeDesc),
|
|
27
|
-
|
|
28
|
+
insertAtEndOfFirstLine(c.description(normalizeDesc), defaultOrOptional),
|
|
29
|
+
ln(1),
|
|
28
30
|
);
|
|
29
31
|
|
|
30
32
|
if (metadata.example) {
|
|
31
|
-
const normalizeExample = metadata.example.replace(/\n/g, "\n" + indent(longest +
|
|
33
|
+
const normalizeExample = metadata.example.replace(/\n/g, "\n" + indent(longest + 16));
|
|
32
34
|
msg += concat(
|
|
33
35
|
indent(longest + 6) + c.punctuation("└") + c.exampleTitle("Example:"),
|
|
34
36
|
c.example(normalizeExample) + ln(1),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stringifyValue } from "src/utils.js";
|
|
2
1
|
import { transformOptionToArg } from "../parser/parse/parser-helpers.js";
|
|
2
|
+
import { stringifyValue } from "../utils.js";
|
|
3
3
|
import { isOptionalSchema, schemaDefaultValue, schemaDescription } from "../zod-utils.js";
|
|
4
4
|
|
|
5
5
|
import type { Option } from "../types.js";
|
package/src/utils.ts
CHANGED
|
@@ -70,3 +70,10 @@ export function stringifyValue(value: unknown): string {
|
|
|
70
70
|
// unknown
|
|
71
71
|
return JSON.stringify(value);
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
/** Insert text at the end of the first line */
|
|
75
|
+
export function insertAtEndOfFirstLine(str: string, insert: string) {
|
|
76
|
+
const lines = str.split("\n");
|
|
77
|
+
lines[0] += " " + insert;
|
|
78
|
+
return lines.join("\n");
|
|
79
|
+
}
|