@cartesi/cli 2.0.0-alpha.23 → 2.0.0-alpha.24
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.js +2 -1
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import{createRequire as jv}from"node:module";var Nv=Object.create;var{getPrototypeOf:Tv,defineProperty:gY,getOwnPropertyNames:Lv}=Object;var Pv=Object.prototype.hasOwnProperty;var ID=(D,F,J)=>{J=D!=null?Nv(Tv(D)):{};let Q=F||!D||!D.__esModule?gY(J,"default",{value:D,enumerable:!0}):J;for(let $ of Lv(D))if(!Pv.call(Q,$))gY(Q,$,{get:()=>D[$],enumerable:!0});return Q};var R=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var K8=(D,F)=>{for(var J in F)gY(D,J,{get:F[J],enumerable:!0,configurable:!0,set:(Q)=>F[J]=()=>Q})};var x=(D,F)=>()=>(D&&(F=D(D=0)),F);var r=jv(import.meta.url);var _9=R((Sv)=>{class mY extends Error{constructor(D,F,J){super(J);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=F,this.exitCode=D,this.nestedError=void 0}}class Dz extends mY{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}Sv.CommanderError=mY;Sv.InvalidArgumentError=Dz});var $J=R((hv)=>{var{InvalidArgumentError:yv}=_9();class Fz{constructor(D,F){switch(this.description=F||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.push(D),F}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,J)=>{if(!this.argChoices.includes(F))throw new yv(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(F,J);return F},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function fv(D){let F=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+F+">":"["+F+"]"}hv.Argument=Fz;hv.humanReadableArgName=fv});var dY=R((gv)=>{var{humanReadableArgName:uv}=$J();class Jz{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let F=D.commands.filter((Q)=>!Q._hidden),J=D._getHelpCommand();if(J&&!J._hidden)F.push(J);if(this.sortSubcommands)F.sort((Q,$)=>{return Q.name().localeCompare($.name())});return F}compareOptions(D,F){let J=(Q)=>{return Q.short?Q.short.replace(/^-/,""):Q.long.replace(/^--/,"")};return J(D).localeCompare(J(F))}visibleOptions(D){let F=D.options.filter((Q)=>!Q.hidden),J=D._getHelpOption();if(J&&!J.hidden){let Q=J.short&&D._findOption(J.short),$=J.long&&D._findOption(J.long);if(!Q&&!$)F.push(J);else if(J.long&&!$)F.push(D.createOption(J.long,J.description));else if(J.short&&!Q)F.push(D.createOption(J.short,J.description))}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let F=[];for(let J=D.parent;J;J=J.parent){let Q=J.options.filter(($)=>!$.hidden);F.push(...Q)}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((F)=>{F.description=F.description||D._argsDescription[F.name()]||""});if(D.registeredArguments.find((F)=>F.description))return D.registeredArguments;return[]}subcommandTerm(D){let F=D.registeredArguments.map((J)=>uv(J)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(F?" "+F:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,F){return F.visibleCommands(D).reduce((J,Q)=>{return Math.max(J,this.displayWidth(F.styleSubcommandTerm(F.subcommandTerm(Q))))},0)}longestOptionTermLength(D,F){return F.visibleOptions(D).reduce((J,Q)=>{return Math.max(J,this.displayWidth(F.styleOptionTerm(F.optionTerm(Q))))},0)}longestGlobalOptionTermLength(D,F){return F.visibleGlobalOptions(D).reduce((J,Q)=>{return Math.max(J,this.displayWidth(F.styleOptionTerm(F.optionTerm(Q))))},0)}longestArgumentTermLength(D,F){return F.visibleArguments(D).reduce((J,Q)=>{return Math.max(J,this.displayWidth(F.styleArgumentTerm(F.argumentTerm(Q))))},0)}commandUsage(D){let F=D._name;if(D._aliases[0])F=F+"|"+D._aliases[0];let J="";for(let Q=D.parent;Q;Q=Q.parent)J=Q.name()+" "+J;return J+F+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)F.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)F.push(`env: ${D.envVar}`);if(F.length>0){let J=`(${F.join(", ")})`;if(D.description)return`${D.description} ${J}`;return J}return D.description}argumentDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(D.defaultValue!==void 0)F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(F.length>0){let J=`(${F.join(", ")})`;if(D.description)return`${D.description} ${J}`;return J}return D.description}formatItemList(D,F,J){if(F.length===0)return[];return[J.styleTitle(D),...F,""]}groupItems(D,F,J){let Q=new Map;return D.forEach(($)=>{let Z=J($);if(!Q.has(Z))Q.set(Z,[])}),F.forEach(($)=>{let Z=J($);if(!Q.has(Z))Q.set(Z,[]);Q.get(Z).push($)}),Q}formatHelp(D,F){let J=F.padWidth(D,F),Q=F.helpWidth??80;function $(W,B){return F.formatItem(W,J,B,F)}let Z=[`${F.styleTitle("Usage:")} ${F.styleUsage(F.commandUsage(D))}`,""],X=F.commandDescription(D);if(X.length>0)Z=Z.concat([F.boxWrap(F.styleCommandDescription(X),Q),""]);let Y=F.visibleArguments(D).map((W)=>{return $(F.styleArgumentTerm(F.argumentTerm(W)),F.styleArgumentDescription(F.argumentDescription(W)))});if(Z=Z.concat(this.formatItemList("Arguments:",Y,F)),this.groupItems(D.options,F.visibleOptions(D),(W)=>W.helpGroupHeading??"Options:").forEach((W,B)=>{let K=W.map((U)=>{return $(F.styleOptionTerm(F.optionTerm(U)),F.styleOptionDescription(F.optionDescription(U)))});Z=Z.concat(this.formatItemList(B,K,F))}),F.showGlobalOptions){let W=F.visibleGlobalOptions(D).map((B)=>{return $(F.styleOptionTerm(F.optionTerm(B)),F.styleOptionDescription(F.optionDescription(B)))});Z=Z.concat(this.formatItemList("Global Options:",W,F))}return this.groupItems(D.commands,F.visibleCommands(D),(W)=>W.helpGroup()||"Commands:").forEach((W,B)=>{let K=W.map((U)=>{return $(F.styleSubcommandTerm(F.subcommandTerm(U)),F.styleSubcommandDescription(F.subcommandDescription(U)))});Z=Z.concat(this.formatItemList(B,K,F))}),Z.join(`
|
|
2
3
|
`)}displayWidth(D){return Qz(D).length}styleTitle(D){return D}styleUsage(D){return D.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F==="[command]")return this.styleSubcommandText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleCommandText(F)}).join(" ")}styleCommandDescription(D){return this.styleDescriptionText(D)}styleOptionDescription(D){return this.styleDescriptionText(D)}styleSubcommandDescription(D){return this.styleDescriptionText(D)}styleArgumentDescription(D){return this.styleDescriptionText(D)}styleDescriptionText(D){return D}styleOptionTerm(D){return this.styleOptionText(D)}styleSubcommandTerm(D){return D.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleSubcommandText(F)}).join(" ")}styleArgumentTerm(D){return this.styleArgumentText(D)}styleOptionText(D){return D}styleArgumentText(D){return D}styleSubcommandText(D){return D}styleCommandText(D){return D}padWidth(D,F){return Math.max(F.longestOptionTermLength(D,F),F.longestGlobalOptionTermLength(D,F),F.longestSubcommandTermLength(D,F),F.longestArgumentTermLength(D,F))}preformatted(D){return/\n[^\S\r\n]/.test(D)}formatItem(D,F,J,Q){let Z=" ".repeat(2);if(!J)return Z+D;let X=D.padEnd(F+D.length-Q.displayWidth(D)),Y=2,G=(this.helpWidth??80)-F-Y-2,W;if(G<this.minWidthToWrap||Q.preformatted(J))W=J;else W=Q.boxWrap(J,G).replace(/\n/g,`
|
|
3
4
|
`+" ".repeat(F+Y));return Z+X+" ".repeat(Y)+W.replace(/\n/g,`
|
|
@@ -688,5 +689,5 @@ http:
|
|
|
688
689
|
\ / CLI
|
|
689
690
|
'`,rXD=new ZD().name("cartesi").version(oXD.version).addHelpText("before",aXD).addCommand($k()).addCommand(Vb()).addCommand(zb()).addCommand(jb()).addCommand(xb(),{hidden:!0}).addCommand(Gv()).addCommand(Uv()).addCommand(Hv()).addCommand(Vv()).addCommand(Mv()).addCommand(Ev()).addCommand(Av()).addCommand(Iv());process.on("uncaughtException",(D)=>{console.error(D),process.exit(1)});rXD.parse();
|
|
690
691
|
|
|
691
|
-
//# debugId=
|
|
692
|
+
//# debugId=5E135D9FC50F231564756E2164756E21
|
|
692
693
|
//# sourceMappingURL=index.js.map
|