@settlemint/sdk-mcp 1.1.16-pr0d9719ab → 1.1.16-prc78f6086

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.
Files changed (3) hide show
  1. package/dist/mcp.js +263 -530
  2. package/dist/mcp.js.map +10 -10
  3. package/package.json +3 -4
package/dist/mcp.js CHANGED
@@ -37563,18 +37563,18 @@ var require_help = __commonJS((exports) => {
37563
37563
  class Help {
37564
37564
  constructor() {
37565
37565
  this.helpWidth = undefined;
37566
- this.minWidthToWrap = 40;
37567
37566
  this.sortSubcommands = false;
37568
37567
  this.sortOptions = false;
37569
37568
  this.showGlobalOptions = false;
37570
37569
  }
37571
- prepareContext(contextOptions) {
37572
- this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
37573
- }
37574
37570
  visibleCommands(cmd) {
37575
37571
  const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
37576
- const helpCommand = cmd._getHelpCommand();
37577
- if (helpCommand && !helpCommand._hidden) {
37572
+ if (cmd._hasImplicitHelpCommand()) {
37573
+ const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
37574
+ const helpCommand = cmd.createCommand(helpName).helpOption(false);
37575
+ helpCommand.description(cmd._helpCommandDescription);
37576
+ if (helpArgs)
37577
+ helpCommand.arguments(helpArgs);
37578
37578
  visibleCommands.push(helpCommand);
37579
37579
  }
37580
37580
  if (this.sortSubcommands) {
@@ -37592,17 +37592,18 @@ var require_help = __commonJS((exports) => {
37592
37592
  }
37593
37593
  visibleOptions(cmd) {
37594
37594
  const visibleOptions = cmd.options.filter((option) => !option.hidden);
37595
- const helpOption = cmd._getHelpOption();
37596
- if (helpOption && !helpOption.hidden) {
37597
- const removeShort = helpOption.short && cmd._findOption(helpOption.short);
37598
- const removeLong = helpOption.long && cmd._findOption(helpOption.long);
37599
- if (!removeShort && !removeLong) {
37600
- visibleOptions.push(helpOption);
37601
- } else if (helpOption.long && !removeLong) {
37602
- visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
37603
- } else if (helpOption.short && !removeShort) {
37604
- visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
37595
+ const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
37596
+ const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
37597
+ if (showShortHelpFlag || showLongHelpFlag) {
37598
+ let helpOption;
37599
+ if (!showShortHelpFlag) {
37600
+ helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
37601
+ } else if (!showLongHelpFlag) {
37602
+ helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
37603
+ } else {
37604
+ helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
37605
37605
  }
37606
+ visibleOptions.push(helpOption);
37606
37607
  }
37607
37608
  if (this.sortOptions) {
37608
37609
  visibleOptions.sort(this.compareOptions);
@@ -37613,8 +37614,8 @@ var require_help = __commonJS((exports) => {
37613
37614
  if (!this.showGlobalOptions)
37614
37615
  return [];
37615
37616
  const globalOptions = [];
37616
- for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
37617
- const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
37617
+ for (let parentCmd = cmd.parent;parentCmd; parentCmd = parentCmd.parent) {
37618
+ const visibleOptions = parentCmd.options.filter((option) => !option.hidden);
37618
37619
  globalOptions.push(...visibleOptions);
37619
37620
  }
37620
37621
  if (this.sortOptions) {
@@ -37624,17 +37625,17 @@ var require_help = __commonJS((exports) => {
37624
37625
  }
37625
37626
  visibleArguments(cmd) {
37626
37627
  if (cmd._argsDescription) {
37627
- cmd.registeredArguments.forEach((argument) => {
37628
+ cmd._args.forEach((argument) => {
37628
37629
  argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
37629
37630
  });
37630
37631
  }
37631
- if (cmd.registeredArguments.find((argument) => argument.description)) {
37632
- return cmd.registeredArguments;
37632
+ if (cmd._args.find((argument) => argument.description)) {
37633
+ return cmd._args;
37633
37634
  }
37634
37635
  return [];
37635
37636
  }
37636
37637
  subcommandTerm(cmd) {
37637
- const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
37638
+ const args = cmd._args.map((arg) => humanReadableArgName(arg)).join(" ");
37638
37639
  return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
37639
37640
  }
37640
37641
  optionTerm(option) {
@@ -37645,22 +37646,22 @@ var require_help = __commonJS((exports) => {
37645
37646
  }
37646
37647
  longestSubcommandTermLength(cmd, helper) {
37647
37648
  return helper.visibleCommands(cmd).reduce((max, command) => {
37648
- return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
37649
+ return Math.max(max, helper.subcommandTerm(command).length);
37649
37650
  }, 0);
37650
37651
  }
37651
37652
  longestOptionTermLength(cmd, helper) {
37652
37653
  return helper.visibleOptions(cmd).reduce((max, option) => {
37653
- return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
37654
+ return Math.max(max, helper.optionTerm(option).length);
37654
37655
  }, 0);
37655
37656
  }
37656
37657
  longestGlobalOptionTermLength(cmd, helper) {
37657
37658
  return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
37658
- return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
37659
+ return Math.max(max, helper.optionTerm(option).length);
37659
37660
  }, 0);
37660
37661
  }
37661
37662
  longestArgumentTermLength(cmd, helper) {
37662
37663
  return helper.visibleArguments(cmd).reduce((max, argument) => {
37663
- return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
37664
+ return Math.max(max, helper.argumentTerm(argument).length);
37664
37665
  }, 0);
37665
37666
  }
37666
37667
  commandUsage(cmd) {
@@ -37668,11 +37669,11 @@ var require_help = __commonJS((exports) => {
37668
37669
  if (cmd._aliases[0]) {
37669
37670
  cmdName = cmdName + "|" + cmd._aliases[0];
37670
37671
  }
37671
- let ancestorCmdNames = "";
37672
- for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
37673
- ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
37672
+ let parentCmdNames = "";
37673
+ for (let parentCmd = cmd.parent;parentCmd; parentCmd = parentCmd.parent) {
37674
+ parentCmdNames = parentCmd.name() + " " + parentCmdNames;
37674
37675
  }
37675
- return ancestorCmdNames + cmdName + " " + cmd.usage();
37676
+ return parentCmdNames + cmdName + " " + cmd.usage();
37676
37677
  }
37677
37678
  commandDescription(cmd) {
37678
37679
  return cmd.description();
@@ -37711,199 +37712,95 @@ var require_help = __commonJS((exports) => {
37711
37712
  extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
37712
37713
  }
37713
37714
  if (extraInfo.length > 0) {
37714
- const extraDescription = `(${extraInfo.join(", ")})`;
37715
+ const extraDescripton = `(${extraInfo.join(", ")})`;
37715
37716
  if (argument.description) {
37716
- return `${argument.description} ${extraDescription}`;
37717
+ return `${argument.description} ${extraDescripton}`;
37717
37718
  }
37718
- return extraDescription;
37719
+ return extraDescripton;
37719
37720
  }
37720
37721
  return argument.description;
37721
37722
  }
37722
37723
  formatHelp(cmd, helper) {
37723
37724
  const termWidth = helper.padWidth(cmd, helper);
37724
- const helpWidth = helper.helpWidth ?? 80;
37725
- function callFormatItem(term, description) {
37726
- return helper.formatItem(term, termWidth, description, helper);
37725
+ const helpWidth = helper.helpWidth || 80;
37726
+ const itemIndentWidth = 2;
37727
+ const itemSeparatorWidth = 2;
37728
+ function formatItem(term, description) {
37729
+ if (description) {
37730
+ const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
37731
+ return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
37732
+ }
37733
+ return term;
37727
37734
  }
37728
- let output = [
37729
- `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
37730
- ""
37731
- ];
37735
+ function formatList(textArray) {
37736
+ return textArray.join(`
37737
+ `).replace(/^/gm, " ".repeat(itemIndentWidth));
37738
+ }
37739
+ let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
37732
37740
  const commandDescription = helper.commandDescription(cmd);
37733
37741
  if (commandDescription.length > 0) {
37734
- output = output.concat([
37735
- helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
37736
- ""
37737
- ]);
37742
+ output = output.concat([helper.wrap(commandDescription, helpWidth, 0), ""]);
37738
37743
  }
37739
37744
  const argumentList = helper.visibleArguments(cmd).map((argument) => {
37740
- return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
37745
+ return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
37741
37746
  });
37742
37747
  if (argumentList.length > 0) {
37743
- output = output.concat([
37744
- helper.styleTitle("Arguments:"),
37745
- ...argumentList,
37746
- ""
37747
- ]);
37748
+ output = output.concat(["Arguments:", formatList(argumentList), ""]);
37748
37749
  }
37749
37750
  const optionList = helper.visibleOptions(cmd).map((option) => {
37750
- return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
37751
+ return formatItem(helper.optionTerm(option), helper.optionDescription(option));
37751
37752
  });
37752
37753
  if (optionList.length > 0) {
37753
- output = output.concat([
37754
- helper.styleTitle("Options:"),
37755
- ...optionList,
37756
- ""
37757
- ]);
37754
+ output = output.concat(["Options:", formatList(optionList), ""]);
37758
37755
  }
37759
- if (helper.showGlobalOptions) {
37756
+ if (this.showGlobalOptions) {
37760
37757
  const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
37761
- return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
37758
+ return formatItem(helper.optionTerm(option), helper.optionDescription(option));
37762
37759
  });
37763
37760
  if (globalOptionList.length > 0) {
37764
- output = output.concat([
37765
- helper.styleTitle("Global Options:"),
37766
- ...globalOptionList,
37767
- ""
37768
- ]);
37761
+ output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
37769
37762
  }
37770
37763
  }
37771
37764
  const commandList = helper.visibleCommands(cmd).map((cmd2) => {
37772
- return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(cmd2)), helper.styleSubcommandDescription(helper.subcommandDescription(cmd2)));
37765
+ return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
37773
37766
  });
37774
37767
  if (commandList.length > 0) {
37775
- output = output.concat([
37776
- helper.styleTitle("Commands:"),
37777
- ...commandList,
37778
- ""
37779
- ]);
37768
+ output = output.concat(["Commands:", formatList(commandList), ""]);
37780
37769
  }
37781
37770
  return output.join(`
37782
37771
  `);
37783
37772
  }
37784
- displayWidth(str) {
37785
- return stripColor(str).length;
37786
- }
37787
- styleTitle(str) {
37788
- return str;
37789
- }
37790
- styleUsage(str) {
37791
- return str.split(" ").map((word) => {
37792
- if (word === "[options]")
37793
- return this.styleOptionText(word);
37794
- if (word === "[command]")
37795
- return this.styleSubcommandText(word);
37796
- if (word[0] === "[" || word[0] === "<")
37797
- return this.styleArgumentText(word);
37798
- return this.styleCommandText(word);
37799
- }).join(" ");
37800
- }
37801
- styleCommandDescription(str) {
37802
- return this.styleDescriptionText(str);
37803
- }
37804
- styleOptionDescription(str) {
37805
- return this.styleDescriptionText(str);
37806
- }
37807
- styleSubcommandDescription(str) {
37808
- return this.styleDescriptionText(str);
37809
- }
37810
- styleArgumentDescription(str) {
37811
- return this.styleDescriptionText(str);
37812
- }
37813
- styleDescriptionText(str) {
37814
- return str;
37815
- }
37816
- styleOptionTerm(str) {
37817
- return this.styleOptionText(str);
37818
- }
37819
- styleSubcommandTerm(str) {
37820
- return str.split(" ").map((word) => {
37821
- if (word === "[options]")
37822
- return this.styleOptionText(word);
37823
- if (word[0] === "[" || word[0] === "<")
37824
- return this.styleArgumentText(word);
37825
- return this.styleSubcommandText(word);
37826
- }).join(" ");
37827
- }
37828
- styleArgumentTerm(str) {
37829
- return this.styleArgumentText(str);
37830
- }
37831
- styleOptionText(str) {
37832
- return str;
37833
- }
37834
- styleArgumentText(str) {
37835
- return str;
37836
- }
37837
- styleSubcommandText(str) {
37838
- return str;
37839
- }
37840
- styleCommandText(str) {
37841
- return str;
37842
- }
37843
37773
  padWidth(cmd, helper) {
37844
37774
  return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
37845
37775
  }
37846
- preformatted(str) {
37847
- return /\n[^\S\r\n]/.test(str);
37848
- }
37849
- formatItem(term, termWidth, description, helper) {
37850
- const itemIndent = 2;
37851
- const itemIndentStr = " ".repeat(itemIndent);
37852
- if (!description)
37853
- return itemIndentStr + term;
37854
- const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
37855
- const spacerWidth = 2;
37856
- const helpWidth = this.helpWidth ?? 80;
37857
- const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
37858
- let formattedDescription;
37859
- if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
37860
- formattedDescription = description;
37861
- } else {
37862
- const wrappedDescription = helper.boxWrap(description, remainingWidth);
37863
- formattedDescription = wrappedDescription.replace(/\n/g, `
37864
- ` + " ".repeat(termWidth + spacerWidth));
37865
- }
37866
- return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
37867
- ${itemIndentStr}`);
37868
- }
37869
- boxWrap(str, width) {
37870
- if (width < this.minWidthToWrap)
37776
+ wrap(str, width, indent2, minColumnWidth = 40) {
37777
+ const indents = " \\f\\t\\v   -    \uFEFF";
37778
+ const manualIndent = new RegExp(`[\\n][${indents}]+`);
37779
+ if (str.match(manualIndent))
37871
37780
  return str;
37872
- const rawLines = str.split(/\r\n|\n/);
37873
- const chunkPattern = /[\s]*[^\s]+/g;
37874
- const wrappedLines = [];
37875
- rawLines.forEach((line) => {
37876
- const chunks = line.match(chunkPattern);
37877
- if (chunks === null) {
37878
- wrappedLines.push("");
37879
- return;
37880
- }
37881
- let sumChunks = [chunks.shift()];
37882
- let sumWidth = this.displayWidth(sumChunks[0]);
37883
- chunks.forEach((chunk) => {
37884
- const visibleWidth = this.displayWidth(chunk);
37885
- if (sumWidth + visibleWidth <= width) {
37886
- sumChunks.push(chunk);
37887
- sumWidth += visibleWidth;
37888
- return;
37889
- }
37890
- wrappedLines.push(sumChunks.join(""));
37891
- const nextChunk = chunk.trimStart();
37892
- sumChunks = [nextChunk];
37893
- sumWidth = this.displayWidth(nextChunk);
37894
- });
37895
- wrappedLines.push(sumChunks.join(""));
37896
- });
37897
- return wrappedLines.join(`
37781
+ const columnWidth = width - indent2;
37782
+ if (columnWidth < minColumnWidth)
37783
+ return str;
37784
+ const leadingStr = str.slice(0, indent2);
37785
+ const columnText = str.slice(indent2).replace(`\r
37786
+ `, `
37787
+ `);
37788
+ const indentString = " ".repeat(indent2);
37789
+ const zeroWidthSpace = "​";
37790
+ const breaks = `\\s${zeroWidthSpace}`;
37791
+ const regex = new RegExp(`
37792
+ |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g");
37793
+ const lines = columnText.match(regex) || [];
37794
+ return leadingStr + lines.map((line, i) => {
37795
+ if (line === `
37796
+ `)
37797
+ return "";
37798
+ return (i > 0 ? indentString : "") + line.trimEnd();
37799
+ }).join(`
37898
37800
  `);
37899
37801
  }
37900
37802
  }
37901
- function stripColor(str) {
37902
- const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
37903
- return str.replace(sgrPattern, "");
37904
- }
37905
37803
  exports.Help = Help;
37906
- exports.stripColor = stripColor;
37907
37804
  });
37908
37805
 
37909
37806
  // ../../node_modules/commander/lib/option.js
@@ -37998,10 +37895,7 @@ var require_option = __commonJS((exports) => {
37998
37895
  return this.short.replace(/^-/, "");
37999
37896
  }
38000
37897
  attributeName() {
38001
- if (this.negate) {
38002
- return camelcase(this.name().replace(/^no-/, ""));
38003
- }
38004
- return camelcase(this.name());
37898
+ return camelcase(this.name().replace(/^no-/, ""));
38005
37899
  }
38006
37900
  is(arg) {
38007
37901
  return this.short === arg || this.long === arg;
@@ -38046,41 +37940,18 @@ var require_option = __commonJS((exports) => {
38046
37940
  function splitOptionFlags(flags) {
38047
37941
  let shortFlag;
38048
37942
  let longFlag;
38049
- const shortFlagExp = /^-[^-]$/;
38050
- const longFlagExp = /^--[^-]/;
38051
- const flagParts = flags.split(/[ |,]+/).concat("guard");
38052
- if (shortFlagExp.test(flagParts[0]))
38053
- shortFlag = flagParts.shift();
38054
- if (longFlagExp.test(flagParts[0]))
38055
- longFlag = flagParts.shift();
38056
- if (!shortFlag && shortFlagExp.test(flagParts[0]))
37943
+ const flagParts = flags.split(/[ |,]+/);
37944
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
38057
37945
  shortFlag = flagParts.shift();
38058
- if (!shortFlag && longFlagExp.test(flagParts[0])) {
37946
+ longFlag = flagParts.shift();
37947
+ if (!shortFlag && /^-[^-]$/.test(longFlag)) {
38059
37948
  shortFlag = longFlag;
38060
- longFlag = flagParts.shift();
38061
- }
38062
- if (flagParts[0].startsWith("-")) {
38063
- const unsupportedFlag = flagParts[0];
38064
- const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
38065
- if (/^-[^-][^-]/.test(unsupportedFlag))
38066
- throw new Error(`${baseError}
38067
- - a short flag is a single dash and a single character
38068
- - either use a single dash and a single character (for a short flag)
38069
- - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
38070
- if (shortFlagExp.test(unsupportedFlag))
38071
- throw new Error(`${baseError}
38072
- - too many short flags`);
38073
- if (longFlagExp.test(unsupportedFlag))
38074
- throw new Error(`${baseError}
38075
- - too many long flags`);
38076
- throw new Error(`${baseError}
38077
- - unrecognised flag format`);
38078
- }
38079
- if (shortFlag === undefined && longFlag === undefined)
38080
- throw new Error(`option creation failed due to no flags found in '${flags}'.`);
37949
+ longFlag = undefined;
37950
+ }
38081
37951
  return { shortFlag, longFlag };
38082
37952
  }
38083
37953
  exports.Option = Option;
37954
+ exports.splitOptionFlags = splitOptionFlags;
38084
37955
  exports.DualOptions = DualOptions;
38085
37956
  });
38086
37957
 
@@ -38159,15 +38030,15 @@ var require_suggestSimilar = __commonJS((exports) => {
38159
38030
 
38160
38031
  // ../../node_modules/commander/lib/command.js
38161
38032
  var require_command = __commonJS((exports) => {
38162
- var EventEmitter2 = __require("node:events").EventEmitter;
38163
- var childProcess = __require("node:child_process");
38164
- var path2 = __require("node:path");
38165
- var fs = __require("node:fs");
38166
- var process3 = __require("node:process");
38033
+ var EventEmitter2 = __require("events").EventEmitter;
38034
+ var childProcess = __require("child_process");
38035
+ var path2 = __require("path");
38036
+ var fs = __require("fs");
38037
+ var process3 = __require("process");
38167
38038
  var { Argument, humanReadableArgName } = require_argument();
38168
38039
  var { CommanderError } = require_error3();
38169
- var { Help, stripColor } = require_help();
38170
- var { Option, DualOptions } = require_option();
38040
+ var { Help } = require_help();
38041
+ var { Option, splitOptionFlags, DualOptions } = require_option();
38171
38042
  var { suggestSimilar } = require_suggestSimilar();
38172
38043
 
38173
38044
  class Command extends EventEmitter2 {
@@ -38177,9 +38048,8 @@ var require_command = __commonJS((exports) => {
38177
38048
  this.options = [];
38178
38049
  this.parent = null;
38179
38050
  this._allowUnknownOption = false;
38180
- this._allowExcessArguments = false;
38181
- this.registeredArguments = [];
38182
- this._args = this.registeredArguments;
38051
+ this._allowExcessArguments = true;
38052
+ this._args = [];
38183
38053
  this.args = [];
38184
38054
  this.rawArgs = [];
38185
38055
  this.processedArgs = [];
@@ -38204,27 +38074,35 @@ var require_command = __commonJS((exports) => {
38204
38074
  this._lifeCycleHooks = {};
38205
38075
  this._showHelpAfterError = false;
38206
38076
  this._showSuggestionAfterError = true;
38207
- this._savedState = null;
38208
38077
  this._outputConfiguration = {
38209
38078
  writeOut: (str) => process3.stdout.write(str),
38210
38079
  writeErr: (str) => process3.stderr.write(str),
38211
- outputError: (str, write) => write(str),
38212
38080
  getOutHelpWidth: () => process3.stdout.isTTY ? process3.stdout.columns : undefined,
38213
38081
  getErrHelpWidth: () => process3.stderr.isTTY ? process3.stderr.columns : undefined,
38214
- getOutHasColors: () => useColor() ?? (process3.stdout.isTTY && process3.stdout.hasColors?.()),
38215
- getErrHasColors: () => useColor() ?? (process3.stderr.isTTY && process3.stderr.hasColors?.()),
38216
- stripColor: (str) => stripColor(str)
38082
+ outputError: (str, write) => write(str)
38217
38083
  };
38218
38084
  this._hidden = false;
38219
- this._helpOption = undefined;
38085
+ this._hasHelpOption = true;
38086
+ this._helpFlags = "-h, --help";
38087
+ this._helpDescription = "display help for command";
38088
+ this._helpShortFlag = "-h";
38089
+ this._helpLongFlag = "--help";
38220
38090
  this._addImplicitHelpCommand = undefined;
38221
- this._helpCommand = undefined;
38091
+ this._helpCommandName = "help";
38092
+ this._helpCommandnameAndArgs = "help [command]";
38093
+ this._helpCommandDescription = "display help for command";
38222
38094
  this._helpConfiguration = {};
38223
38095
  }
38224
38096
  copyInheritedSettings(sourceCommand) {
38225
38097
  this._outputConfiguration = sourceCommand._outputConfiguration;
38226
- this._helpOption = sourceCommand._helpOption;
38227
- this._helpCommand = sourceCommand._helpCommand;
38098
+ this._hasHelpOption = sourceCommand._hasHelpOption;
38099
+ this._helpFlags = sourceCommand._helpFlags;
38100
+ this._helpDescription = sourceCommand._helpDescription;
38101
+ this._helpShortFlag = sourceCommand._helpShortFlag;
38102
+ this._helpLongFlag = sourceCommand._helpLongFlag;
38103
+ this._helpCommandName = sourceCommand._helpCommandName;
38104
+ this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;
38105
+ this._helpCommandDescription = sourceCommand._helpCommandDescription;
38228
38106
  this._helpConfiguration = sourceCommand._helpConfiguration;
38229
38107
  this._exitCallback = sourceCommand._exitCallback;
38230
38108
  this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
@@ -38235,13 +38113,6 @@ var require_command = __commonJS((exports) => {
38235
38113
  this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
38236
38114
  return this;
38237
38115
  }
38238
- _getCommandAndAncestors() {
38239
- const result = [];
38240
- for (let command = this;command; command = command.parent) {
38241
- result.push(command);
38242
- }
38243
- return result;
38244
- }
38245
38116
  command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
38246
38117
  let desc = actionOptsOrExecDesc;
38247
38118
  let opts = execOpts;
@@ -38262,7 +38133,7 @@ var require_command = __commonJS((exports) => {
38262
38133
  cmd._executableFile = opts.executableFile || null;
38263
38134
  if (args)
38264
38135
  cmd.arguments(args);
38265
- this._registerCommand(cmd);
38136
+ this.commands.push(cmd);
38266
38137
  cmd.parent = this;
38267
38138
  cmd.copyInheritedSettings(this);
38268
38139
  if (desc)
@@ -38307,9 +38178,8 @@ var require_command = __commonJS((exports) => {
38307
38178
  this._defaultCommandName = cmd._name;
38308
38179
  if (opts.noHelp || opts.hidden)
38309
38180
  cmd._hidden = true;
38310
- this._registerCommand(cmd);
38181
+ this.commands.push(cmd);
38311
38182
  cmd.parent = this;
38312
- cmd._checkForBrokenPassThrough();
38313
38183
  return this;
38314
38184
  }
38315
38185
  createArgument(name, description) {
@@ -38326,58 +38196,40 @@ var require_command = __commonJS((exports) => {
38326
38196
  return this;
38327
38197
  }
38328
38198
  arguments(names) {
38329
- names.trim().split(/ +/).forEach((detail) => {
38199
+ names.split(/ +/).forEach((detail) => {
38330
38200
  this.argument(detail);
38331
38201
  });
38332
38202
  return this;
38333
38203
  }
38334
38204
  addArgument(argument) {
38335
- const previousArgument = this.registeredArguments.slice(-1)[0];
38205
+ const previousArgument = this._args.slice(-1)[0];
38336
38206
  if (previousArgument && previousArgument.variadic) {
38337
38207
  throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
38338
38208
  }
38339
38209
  if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
38340
38210
  throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
38341
38211
  }
38342
- this.registeredArguments.push(argument);
38212
+ this._args.push(argument);
38343
38213
  return this;
38344
38214
  }
38345
- helpCommand(enableOrNameAndArgs, description) {
38346
- if (typeof enableOrNameAndArgs === "boolean") {
38347
- this._addImplicitHelpCommand = enableOrNameAndArgs;
38348
- return this;
38349
- }
38350
- enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]";
38351
- const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);
38352
- const helpDescription = description ?? "display help for command";
38353
- const helpCommand = this.createCommand(helpName);
38354
- helpCommand.helpOption(false);
38355
- if (helpArgs)
38356
- helpCommand.arguments(helpArgs);
38357
- if (helpDescription)
38358
- helpCommand.description(helpDescription);
38359
- this._addImplicitHelpCommand = true;
38360
- this._helpCommand = helpCommand;
38361
- return this;
38362
- }
38363
- addHelpCommand(helpCommand, deprecatedDescription) {
38364
- if (typeof helpCommand !== "object") {
38365
- this.helpCommand(helpCommand, deprecatedDescription);
38366
- return this;
38215
+ addHelpCommand(enableOrNameAndArgs, description) {
38216
+ if (enableOrNameAndArgs === false) {
38217
+ this._addImplicitHelpCommand = false;
38218
+ } else {
38219
+ this._addImplicitHelpCommand = true;
38220
+ if (typeof enableOrNameAndArgs === "string") {
38221
+ this._helpCommandName = enableOrNameAndArgs.split(" ")[0];
38222
+ this._helpCommandnameAndArgs = enableOrNameAndArgs;
38223
+ }
38224
+ this._helpCommandDescription = description || this._helpCommandDescription;
38367
38225
  }
38368
- this._addImplicitHelpCommand = true;
38369
- this._helpCommand = helpCommand;
38370
38226
  return this;
38371
38227
  }
38372
- _getHelpCommand() {
38373
- const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
38374
- if (hasImplicitHelpCommand) {
38375
- if (this._helpCommand === undefined) {
38376
- this.helpCommand(undefined, undefined);
38377
- }
38378
- return this._helpCommand;
38228
+ _hasImplicitHelpCommand() {
38229
+ if (this._addImplicitHelpCommand === undefined) {
38230
+ return this.commands.length && !this._actionHandler && !this._findCommand("help");
38379
38231
  }
38380
- return null;
38232
+ return this._addImplicitHelpCommand;
38381
38233
  }
38382
38234
  hook(event, listener) {
38383
38235
  const allowedValues = ["preSubcommand", "preAction", "postAction"];
@@ -38413,7 +38265,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38413
38265
  }
38414
38266
  action(fn) {
38415
38267
  const listener = (args) => {
38416
- const expectedArgsCount = this.registeredArguments.length;
38268
+ const expectedArgsCount = this._args.length;
38417
38269
  const actionArgs = args.slice(0, expectedArgsCount);
38418
38270
  if (this._storeOptionsAsProperties) {
38419
38271
  actionArgs[expectedArgsCount] = this;
@@ -38429,40 +38281,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38429
38281
  createOption(flags, description) {
38430
38282
  return new Option(flags, description);
38431
38283
  }
38432
- _callParseArg(target, value, previous, invalidArgumentMessage) {
38433
- try {
38434
- return target.parseArg(value, previous);
38435
- } catch (err) {
38436
- if (err.code === "commander.invalidArgument") {
38437
- const message = `${invalidArgumentMessage} ${err.message}`;
38438
- this.error(message, { exitCode: err.exitCode, code: err.code });
38439
- }
38440
- throw err;
38441
- }
38442
- }
38443
- _registerOption(option) {
38444
- const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
38445
- if (matchingOption) {
38446
- const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
38447
- throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
38448
- - already used by option '${matchingOption.flags}'`);
38449
- }
38450
- this.options.push(option);
38451
- }
38452
- _registerCommand(command) {
38453
- const knownBy = (cmd) => {
38454
- return [cmd.name()].concat(cmd.aliases());
38455
- };
38456
- const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
38457
- if (alreadyUsed) {
38458
- const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
38459
- const newCmd = knownBy(command).join("|");
38460
- throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
38461
- }
38462
- this.commands.push(command);
38463
- }
38464
38284
  addOption(option) {
38465
- this._registerOption(option);
38466
38285
  const oname = option.name();
38467
38286
  const name = option.attributeName();
38468
38287
  if (option.negate) {
@@ -38473,13 +38292,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
38473
38292
  } else if (option.defaultValue !== undefined) {
38474
38293
  this.setOptionValueWithSource(name, option.defaultValue, "default");
38475
38294
  }
38295
+ this.options.push(option);
38476
38296
  const handleOptionValue = (val, invalidValueMessage, valueSource) => {
38477
38297
  if (val == null && option.presetArg !== undefined) {
38478
38298
  val = option.presetArg;
38479
38299
  }
38480
38300
  const oldValue = this.getOptionValue(name);
38481
38301
  if (val !== null && option.parseArg) {
38482
- val = this._callParseArg(option, val, oldValue, invalidValueMessage);
38302
+ try {
38303
+ val = option.parseArg(val, oldValue);
38304
+ } catch (err) {
38305
+ if (err.code === "commander.invalidArgument") {
38306
+ const message = `${invalidValueMessage} ${err.message}`;
38307
+ this.error(message, { exitCode: err.exitCode, code: err.code });
38308
+ }
38309
+ throw err;
38310
+ }
38483
38311
  } else if (val !== null && option.variadic) {
38484
38312
  val = option._concatValue(val, oldValue);
38485
38313
  }
@@ -38526,11 +38354,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
38526
38354
  }
38527
38355
  return this.addOption(option);
38528
38356
  }
38529
- option(flags, description, parseArg, defaultValue) {
38530
- return this._optionEx({}, flags, description, parseArg, defaultValue);
38357
+ option(flags, description, fn, defaultValue) {
38358
+ return this._optionEx({}, flags, description, fn, defaultValue);
38531
38359
  }
38532
- requiredOption(flags, description, parseArg, defaultValue) {
38533
- return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
38360
+ requiredOption(flags, description, fn, defaultValue) {
38361
+ return this._optionEx({ mandatory: true }, flags, description, fn, defaultValue);
38534
38362
  }
38535
38363
  combineFlagAndOptionalValue(combine = true) {
38536
38364
  this._combineFlagAndOptionalValue = !!combine;
@@ -38550,22 +38378,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
38550
38378
  }
38551
38379
  passThroughOptions(passThrough = true) {
38552
38380
  this._passThroughOptions = !!passThrough;
38553
- this._checkForBrokenPassThrough();
38554
- return this;
38555
- }
38556
- _checkForBrokenPassThrough() {
38557
- if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
38558
- throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
38381
+ if (!!this.parent && passThrough && !this.parent._enablePositionalOptions) {
38382
+ throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
38559
38383
  }
38384
+ return this;
38560
38385
  }
38561
38386
  storeOptionsAsProperties(storeAsProperties = true) {
38387
+ this._storeOptionsAsProperties = !!storeAsProperties;
38562
38388
  if (this.options.length) {
38563
38389
  throw new Error("call .storeOptionsAsProperties() before adding options");
38564
38390
  }
38565
- if (Object.keys(this._optionValues).length) {
38566
- throw new Error("call .storeOptionsAsProperties() before setting option values");
38567
- }
38568
- this._storeOptionsAsProperties = !!storeAsProperties;
38569
38391
  return this;
38570
38392
  }
38571
38393
  getOptionValue(key) {
@@ -38591,7 +38413,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38591
38413
  }
38592
38414
  getOptionValueSourceWithGlobals(key) {
38593
38415
  let source;
38594
- this._getCommandAndAncestors().forEach((cmd) => {
38416
+ getCommandAndParents(this).forEach((cmd) => {
38595
38417
  if (cmd.getOptionValueSource(key) !== undefined) {
38596
38418
  source = cmd.getOptionValueSource(key);
38597
38419
  }
@@ -38603,17 +38425,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
38603
38425
  throw new Error("first parameter to parse must be array or undefined");
38604
38426
  }
38605
38427
  parseOptions = parseOptions || {};
38606
- if (argv === undefined && parseOptions.from === undefined) {
38607
- if (process3.versions?.electron) {
38608
- parseOptions.from = "electron";
38609
- }
38610
- const execArgv = process3.execArgv ?? [];
38611
- if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
38612
- parseOptions.from = "eval";
38613
- }
38614
- }
38615
38428
  if (argv === undefined) {
38616
38429
  argv = process3.argv;
38430
+ if (process3.versions && process3.versions.electron) {
38431
+ parseOptions.from = "electron";
38432
+ }
38617
38433
  }
38618
38434
  this.rawArgs = argv.slice();
38619
38435
  let userArgs;
@@ -38634,9 +38450,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
38634
38450
  case "user":
38635
38451
  userArgs = argv.slice(0);
38636
38452
  break;
38637
- case "eval":
38638
- userArgs = argv.slice(1);
38639
- break;
38640
38453
  default:
38641
38454
  throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
38642
38455
  }
@@ -38646,53 +38459,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
38646
38459
  return userArgs;
38647
38460
  }
38648
38461
  parse(argv, parseOptions) {
38649
- this._prepareForParse();
38650
38462
  const userArgs = this._prepareUserArgs(argv, parseOptions);
38651
38463
  this._parseCommand([], userArgs);
38652
38464
  return this;
38653
38465
  }
38654
38466
  async parseAsync(argv, parseOptions) {
38655
- this._prepareForParse();
38656
38467
  const userArgs = this._prepareUserArgs(argv, parseOptions);
38657
38468
  await this._parseCommand([], userArgs);
38658
38469
  return this;
38659
38470
  }
38660
- _prepareForParse() {
38661
- if (this._savedState === null) {
38662
- this.saveStateBeforeParse();
38663
- } else {
38664
- this.restoreStateBeforeParse();
38665
- }
38666
- }
38667
- saveStateBeforeParse() {
38668
- this._savedState = {
38669
- _name: this._name,
38670
- _optionValues: { ...this._optionValues },
38671
- _optionValueSources: { ...this._optionValueSources }
38672
- };
38673
- }
38674
- restoreStateBeforeParse() {
38675
- if (this._storeOptionsAsProperties)
38676
- throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
38677
- - either make a new Command for each call to parse, or stop storing options as properties`);
38678
- this._name = this._savedState._name;
38679
- this._scriptPath = null;
38680
- this.rawArgs = [];
38681
- this._optionValues = { ...this._savedState._optionValues };
38682
- this._optionValueSources = { ...this._savedState._optionValueSources };
38683
- this.args = [];
38684
- this.processedArgs = [];
38685
- }
38686
- _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
38687
- if (fs.existsSync(executableFile))
38688
- return;
38689
- const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
38690
- const executableMissing = `'${executableFile}' does not exist
38691
- - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
38692
- - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
38693
- - ${executableDirMessage}`;
38694
- throw new Error(executableMissing);
38695
- }
38696
38471
  _executeSubCommand(subcommand, args) {
38697
38472
  args = args.slice();
38698
38473
  let launchWithNode = false;
@@ -38716,7 +38491,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38716
38491
  let resolvedScriptPath;
38717
38492
  try {
38718
38493
  resolvedScriptPath = fs.realpathSync(this._scriptPath);
38719
- } catch {
38494
+ } catch (err) {
38720
38495
  resolvedScriptPath = this._scriptPath;
38721
38496
  }
38722
38497
  executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
@@ -38742,7 +38517,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
38742
38517
  proc2 = childProcess.spawn(executableFile, args, { stdio: "inherit" });
38743
38518
  }
38744
38519
  } else {
38745
- this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
38746
38520
  args.unshift(executableFile);
38747
38521
  args = incrementNodeInspectorPort(process3.execArgv).concat(args);
38748
38522
  proc2 = childProcess.spawn(process3.execPath, args, { stdio: "inherit" });
@@ -38758,17 +38532,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
38758
38532
  });
38759
38533
  }
38760
38534
  const exitCallback = this._exitCallback;
38761
- proc2.on("close", (code) => {
38762
- code = code ?? 1;
38763
- if (!exitCallback) {
38764
- process3.exit(code);
38765
- } else {
38766
- exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
38767
- }
38768
- });
38535
+ if (!exitCallback) {
38536
+ proc2.on("close", process3.exit.bind(process3));
38537
+ } else {
38538
+ proc2.on("close", () => {
38539
+ exitCallback(new CommanderError(process3.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
38540
+ });
38541
+ }
38769
38542
  proc2.on("error", (err) => {
38770
38543
  if (err.code === "ENOENT") {
38771
- this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
38544
+ const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
38545
+ const executableMissing = `'${executableFile}' does not exist
38546
+ - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
38547
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
38548
+ - ${executableDirMessage}`;
38549
+ throw new Error(executableMissing);
38772
38550
  } else if (err.code === "EACCES") {
38773
38551
  throw new Error(`'${executableFile}' not executable`);
38774
38552
  }
@@ -38786,38 +38564,27 @@ Expecting one of '${allowedValues.join("', '")}'`);
38786
38564
  const subCommand = this._findCommand(commandName);
38787
38565
  if (!subCommand)
38788
38566
  this.help({ error: true });
38789
- subCommand._prepareForParse();
38790
- let promiseChain;
38791
- promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
38792
- promiseChain = this._chainOrCall(promiseChain, () => {
38567
+ let hookResult;
38568
+ hookResult = this._chainOrCallSubCommandHook(hookResult, subCommand, "preSubcommand");
38569
+ hookResult = this._chainOrCall(hookResult, () => {
38793
38570
  if (subCommand._executableHandler) {
38794
38571
  this._executeSubCommand(subCommand, operands.concat(unknown2));
38795
38572
  } else {
38796
38573
  return subCommand._parseCommand(operands, unknown2);
38797
38574
  }
38798
38575
  });
38799
- return promiseChain;
38800
- }
38801
- _dispatchHelpCommand(subcommandName) {
38802
- if (!subcommandName) {
38803
- this.help();
38804
- }
38805
- const subCommand = this._findCommand(subcommandName);
38806
- if (subCommand && !subCommand._executableHandler) {
38807
- subCommand.help();
38808
- }
38809
- return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
38576
+ return hookResult;
38810
38577
  }
38811
38578
  _checkNumberOfArguments() {
38812
- this.registeredArguments.forEach((arg, i) => {
38579
+ this._args.forEach((arg, i) => {
38813
38580
  if (arg.required && this.args[i] == null) {
38814
38581
  this.missingArgument(arg.name());
38815
38582
  }
38816
38583
  });
38817
- if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
38584
+ if (this._args.length > 0 && this._args[this._args.length - 1].variadic) {
38818
38585
  return;
38819
38586
  }
38820
- if (this.args.length > this.registeredArguments.length) {
38587
+ if (this.args.length > this._args.length) {
38821
38588
  this._excessArguments(this.args);
38822
38589
  }
38823
38590
  }
@@ -38825,14 +38592,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
38825
38592
  const myParseArg = (argument, value, previous) => {
38826
38593
  let parsedValue = value;
38827
38594
  if (value !== null && argument.parseArg) {
38828
- const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
38829
- parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
38595
+ try {
38596
+ parsedValue = argument.parseArg(value, previous);
38597
+ } catch (err) {
38598
+ if (err.code === "commander.invalidArgument") {
38599
+ const message = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'. ${err.message}`;
38600
+ this.error(message, { exitCode: err.exitCode, code: err.code });
38601
+ }
38602
+ throw err;
38603
+ }
38830
38604
  }
38831
38605
  return parsedValue;
38832
38606
  };
38833
38607
  this._checkNumberOfArguments();
38834
38608
  const processedArgs = [];
38835
- this.registeredArguments.forEach((declaredArg, index) => {
38609
+ this._args.forEach((declaredArg, index) => {
38836
38610
  let value = declaredArg.defaultValue;
38837
38611
  if (declaredArg.variadic) {
38838
38612
  if (index < this.args.length) {
@@ -38864,7 +38638,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
38864
38638
  _chainOrCallHooks(promise2, event) {
38865
38639
  let result = promise2;
38866
38640
  const hooks = [];
38867
- this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
38641
+ getCommandAndParents(this).reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
38868
38642
  hookedCommand._lifeCycleHooks[event].forEach((callback) => {
38869
38643
  hooks.push({ hookedCommand, callback });
38870
38644
  });
@@ -38900,17 +38674,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
38900
38674
  if (operands && this._findCommand(operands[0])) {
38901
38675
  return this._dispatchSubcommand(operands[0], operands.slice(1), unknown2);
38902
38676
  }
38903
- if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
38904
- return this._dispatchHelpCommand(operands[1]);
38677
+ if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {
38678
+ if (operands.length === 1) {
38679
+ this.help();
38680
+ }
38681
+ return this._dispatchSubcommand(operands[1], [], [this._helpLongFlag]);
38905
38682
  }
38906
38683
  if (this._defaultCommandName) {
38907
- this._outputHelpIfRequested(unknown2);
38684
+ outputHelpIfRequested(this, unknown2);
38908
38685
  return this._dispatchSubcommand(this._defaultCommandName, operands, unknown2);
38909
38686
  }
38910
38687
  if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
38911
38688
  this.help({ error: true });
38912
38689
  }
38913
- this._outputHelpIfRequested(parsed.unknown);
38690
+ outputHelpIfRequested(this, parsed.unknown);
38914
38691
  this._checkForMissingMandatoryOptions();
38915
38692
  this._checkForConflictingOptions();
38916
38693
  const checkForUnknownOptions = () => {
@@ -38922,16 +38699,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
38922
38699
  if (this._actionHandler) {
38923
38700
  checkForUnknownOptions();
38924
38701
  this._processArguments();
38925
- let promiseChain;
38926
- promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
38927
- promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
38702
+ let actionResult;
38703
+ actionResult = this._chainOrCallHooks(actionResult, "preAction");
38704
+ actionResult = this._chainOrCall(actionResult, () => this._actionHandler(this.processedArgs));
38928
38705
  if (this.parent) {
38929
- promiseChain = this._chainOrCall(promiseChain, () => {
38706
+ actionResult = this._chainOrCall(actionResult, () => {
38930
38707
  this.parent.emit(commandEvent, operands, unknown2);
38931
38708
  });
38932
38709
  }
38933
- promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
38934
- return promiseChain;
38710
+ actionResult = this._chainOrCallHooks(actionResult, "postAction");
38711
+ return actionResult;
38935
38712
  }
38936
38713
  if (this.parent && this.parent.listenerCount(commandEvent)) {
38937
38714
  checkForUnknownOptions();
@@ -38966,13 +38743,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
38966
38743
  return this.options.find((option) => option.is(arg));
38967
38744
  }
38968
38745
  _checkForMissingMandatoryOptions() {
38969
- this._getCommandAndAncestors().forEach((cmd) => {
38746
+ for (let cmd = this;cmd; cmd = cmd.parent) {
38970
38747
  cmd.options.forEach((anOption) => {
38971
38748
  if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) {
38972
38749
  cmd.missingMandatoryOptionValue(anOption);
38973
38750
  }
38974
38751
  });
38975
- });
38752
+ }
38976
38753
  }
38977
38754
  _checkForConflictingLocalOptions() {
38978
38755
  const definedNonDefaultOptions = this.options.filter((option) => {
@@ -38991,9 +38768,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
38991
38768
  });
38992
38769
  }
38993
38770
  _checkForConflictingOptions() {
38994
- this._getCommandAndAncestors().forEach((cmd) => {
38771
+ for (let cmd = this;cmd; cmd = cmd.parent) {
38995
38772
  cmd._checkForConflictingLocalOptions();
38996
- });
38773
+ }
38997
38774
  }
38998
38775
  parseOptions(argv) {
38999
38776
  const operands = [];
@@ -39067,7 +38844,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
39067
38844
  if (args.length > 0)
39068
38845
  unknown2.push(...args);
39069
38846
  break;
39070
- } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
38847
+ } else if (arg === this._helpCommandName && this._hasImplicitHelpCommand()) {
39071
38848
  operands.push(arg);
39072
38849
  if (args.length > 0)
39073
38850
  operands.push(...args);
@@ -39102,7 +38879,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
39102
38879
  return this._optionValues;
39103
38880
  }
39104
38881
  optsWithGlobals() {
39105
- return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
38882
+ return getCommandAndParents(this).reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
39106
38883
  }
39107
38884
  error(message, errorOptions) {
39108
38885
  this._outputConfiguration.outputError(`${message}
@@ -39200,7 +38977,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
39200
38977
  _excessArguments(receivedArgs) {
39201
38978
  if (this._allowExcessArguments)
39202
38979
  return;
39203
- const expected = this.registeredArguments.length;
38980
+ const expected = this._args.length;
39204
38981
  const s = expected === 1 ? "" : "s";
39205
38982
  const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
39206
38983
  const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
@@ -39229,7 +39006,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
39229
39006
  description = description || "output the version number";
39230
39007
  const versionOption = this.createOption(flags, description);
39231
39008
  this._versionOptionName = versionOption.attributeName();
39232
- this._registerOption(versionOption);
39009
+ this.options.push(versionOption);
39233
39010
  this.on("option:" + versionOption.name(), () => {
39234
39011
  this._outputConfiguration.writeOut(`${str}
39235
39012
  `);
@@ -39261,11 +39038,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
39261
39038
  }
39262
39039
  if (alias === command._name)
39263
39040
  throw new Error("Command alias can't be the same as its name");
39264
- const matchingCommand = this.parent?._findCommand(alias);
39265
- if (matchingCommand) {
39266
- const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
39267
- throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
39268
- }
39269
39041
  command._aliases.push(alias);
39270
39042
  return this;
39271
39043
  }
@@ -39279,10 +39051,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
39279
39051
  if (str === undefined) {
39280
39052
  if (this._usage)
39281
39053
  return this._usage;
39282
- const args = this.registeredArguments.map((arg) => {
39054
+ const args = this._args.map((arg) => {
39283
39055
  return humanReadableArgName(arg);
39284
39056
  });
39285
- return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
39057
+ return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this._args.length ? args : []).join(" ");
39286
39058
  }
39287
39059
  this._usage = str;
39288
39060
  return this;
@@ -39305,38 +39077,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
39305
39077
  }
39306
39078
  helpInformation(contextOptions) {
39307
39079
  const helper = this.createHelp();
39308
- const context = this._getOutputContext(contextOptions);
39309
- helper.prepareContext({
39310
- error: context.error,
39311
- helpWidth: context.helpWidth,
39312
- outputHasColors: context.hasColors
39313
- });
39314
- const text = helper.formatHelp(this, helper);
39315
- if (context.hasColors)
39316
- return text;
39317
- return this._outputConfiguration.stripColor(text);
39080
+ if (helper.helpWidth === undefined) {
39081
+ helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
39082
+ }
39083
+ return helper.formatHelp(this, helper);
39318
39084
  }
39319
- _getOutputContext(contextOptions) {
39085
+ _getHelpContext(contextOptions) {
39320
39086
  contextOptions = contextOptions || {};
39321
- const error = !!contextOptions.error;
39322
- let baseWrite;
39323
- let hasColors2;
39324
- let helpWidth;
39325
- if (error) {
39326
- baseWrite = (str) => this._outputConfiguration.writeErr(str);
39327
- hasColors2 = this._outputConfiguration.getErrHasColors();
39328
- helpWidth = this._outputConfiguration.getErrHelpWidth();
39087
+ const context = { error: !!contextOptions.error };
39088
+ let write;
39089
+ if (context.error) {
39090
+ write = (arg) => this._outputConfiguration.writeErr(arg);
39329
39091
  } else {
39330
- baseWrite = (str) => this._outputConfiguration.writeOut(str);
39331
- hasColors2 = this._outputConfiguration.getOutHasColors();
39332
- helpWidth = this._outputConfiguration.getOutHelpWidth();
39333
- }
39334
- const write = (str) => {
39335
- if (!hasColors2)
39336
- str = this._outputConfiguration.stripColor(str);
39337
- return baseWrite(str);
39338
- };
39339
- return { error, write, hasColors: hasColors2, helpWidth };
39092
+ write = (arg) => this._outputConfiguration.writeOut(arg);
39093
+ }
39094
+ context.write = contextOptions.write || write;
39095
+ context.command = this;
39096
+ return context;
39340
39097
  }
39341
39098
  outputHelp(contextOptions) {
39342
39099
  let deprecatedCallback;
@@ -39344,55 +39101,36 @@ Expecting one of '${allowedValues.join("', '")}'`);
39344
39101
  deprecatedCallback = contextOptions;
39345
39102
  contextOptions = undefined;
39346
39103
  }
39347
- const outputContext = this._getOutputContext(contextOptions);
39348
- const eventContext = {
39349
- error: outputContext.error,
39350
- write: outputContext.write,
39351
- command: this
39352
- };
39353
- this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
39354
- this.emit("beforeHelp", eventContext);
39355
- let helpInformation = this.helpInformation({ error: outputContext.error });
39104
+ const context = this._getHelpContext(contextOptions);
39105
+ getCommandAndParents(this).reverse().forEach((command) => command.emit("beforeAllHelp", context));
39106
+ this.emit("beforeHelp", context);
39107
+ let helpInformation = this.helpInformation(context);
39356
39108
  if (deprecatedCallback) {
39357
39109
  helpInformation = deprecatedCallback(helpInformation);
39358
39110
  if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
39359
39111
  throw new Error("outputHelp callback must return a string or a Buffer");
39360
39112
  }
39361
39113
  }
39362
- outputContext.write(helpInformation);
39363
- if (this._getHelpOption()?.long) {
39364
- this.emit(this._getHelpOption().long);
39365
- }
39366
- this.emit("afterHelp", eventContext);
39367
- this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
39114
+ context.write(helpInformation);
39115
+ this.emit(this._helpLongFlag);
39116
+ this.emit("afterHelp", context);
39117
+ getCommandAndParents(this).forEach((command) => command.emit("afterAllHelp", context));
39368
39118
  }
39369
39119
  helpOption(flags, description) {
39370
39120
  if (typeof flags === "boolean") {
39371
- if (flags) {
39372
- this._helpOption = this._helpOption ?? undefined;
39373
- } else {
39374
- this._helpOption = null;
39375
- }
39121
+ this._hasHelpOption = flags;
39376
39122
  return this;
39377
39123
  }
39378
- flags = flags ?? "-h, --help";
39379
- description = description ?? "display help for command";
39380
- this._helpOption = this.createOption(flags, description);
39381
- return this;
39382
- }
39383
- _getHelpOption() {
39384
- if (this._helpOption === undefined) {
39385
- this.helpOption(undefined, undefined);
39386
- }
39387
- return this._helpOption;
39388
- }
39389
- addHelpOption(option) {
39390
- this._helpOption = option;
39124
+ this._helpFlags = flags || this._helpFlags;
39125
+ this._helpDescription = description || this._helpDescription;
39126
+ const helpFlags = splitOptionFlags(this._helpFlags);
39127
+ this._helpShortFlag = helpFlags.shortFlag;
39128
+ this._helpLongFlag = helpFlags.longFlag;
39391
39129
  return this;
39392
39130
  }
39393
39131
  help(contextOptions) {
39394
39132
  this.outputHelp(contextOptions);
39395
- let exitCode = Number(process3.exitCode ?? 0);
39133
+ let exitCode = process3.exitCode || 0;
39396
39134
  if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
39397
39135
  exitCode = 1;
39398
39136
  }
@@ -39419,13 +39157,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
39419
39157
  });
39420
39158
  return this;
39421
39159
  }
39422
- _outputHelpIfRequested(args) {
39423
- const helpOption = this._getHelpOption();
39424
- const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
39425
- if (helpRequested) {
39426
- this.outputHelp();
39427
- this._exit(0, "commander.helpDisplayed", "(outputHelp)");
39428
- }
39160
+ }
39161
+ function outputHelpIfRequested(cmd, args) {
39162
+ const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
39163
+ if (helpOption) {
39164
+ cmd.outputHelp();
39165
+ cmd._exit(0, "commander.helpDisplayed", "(outputHelp)");
39429
39166
  }
39430
39167
  }
39431
39168
  function incrementNodeInspectorPort(args) {
@@ -39457,35 +39194,32 @@ Expecting one of '${allowedValues.join("', '")}'`);
39457
39194
  return arg;
39458
39195
  });
39459
39196
  }
39460
- function useColor() {
39461
- if (process3.env.NO_COLOR || process3.env.FORCE_COLOR === "0" || process3.env.FORCE_COLOR === "false")
39462
- return false;
39463
- if (process3.env.FORCE_COLOR || process3.env.CLICOLOR_FORCE !== undefined)
39464
- return true;
39465
- return;
39197
+ function getCommandAndParents(startCommand) {
39198
+ const result = [];
39199
+ for (let command = startCommand;command; command = command.parent) {
39200
+ result.push(command);
39201
+ }
39202
+ return result;
39466
39203
  }
39467
39204
  exports.Command = Command;
39468
- exports.useColor = useColor;
39469
39205
  });
39470
39206
 
39471
39207
  // ../../node_modules/commander/index.js
39472
- var require_commander = __commonJS((exports) => {
39208
+ var require_commander = __commonJS((exports, module) => {
39473
39209
  var { Argument } = require_argument();
39474
39210
  var { Command } = require_command();
39475
39211
  var { CommanderError, InvalidArgumentError } = require_error3();
39476
39212
  var { Help } = require_help();
39477
39213
  var { Option } = require_option();
39478
- exports.program = new Command;
39479
- exports.createCommand = (name) => new Command(name);
39480
- exports.createOption = (flags, description) => new Option(flags, description);
39481
- exports.createArgument = (name, description) => new Argument(name, description);
39482
- exports.Command = Command;
39483
- exports.Option = Option;
39214
+ exports = module.exports = new Command;
39215
+ exports.program = exports;
39484
39216
  exports.Argument = Argument;
39485
- exports.Help = Help;
39217
+ exports.Command = Command;
39486
39218
  exports.CommanderError = CommanderError;
39219
+ exports.Help = Help;
39487
39220
  exports.InvalidArgumentError = InvalidArgumentError;
39488
39221
  exports.InvalidOptionArgumentError = InvalidArgumentError;
39222
+ exports.Option = Option;
39489
39223
  });
39490
39224
  // ../../node_modules/@graphql-tools/utils/esm/helpers.js
39491
39225
  var import_graphql = __toESM(require_graphql2(), 1);
@@ -62894,7 +62628,7 @@ var {
62894
62628
  var package_default = {
62895
62629
  name: "@settlemint/sdk-mcp",
62896
62630
  description: "MCP interface for SettleMint SDK, providing development tools and project management capabilities",
62897
- version: "1.1.16-pr0d9719ab",
62631
+ version: "1.1.16-prc78f6086",
62898
62632
  type: "module",
62899
62633
  private: false,
62900
62634
  license: "FSL-1.1-MIT",
@@ -62937,10 +62671,9 @@ var package_default = {
62937
62671
  "@graphql-tools/load": "8.0.17",
62938
62672
  "@graphql-tools/url-loader": "8.0.29",
62939
62673
  "@modelcontextprotocol/sdk": "1.6.1",
62940
- "@settlemint/sdk-js": "1.1.16-pr0d9719ab",
62941
- "@settlemint/sdk-utils": "1.1.16-pr0d9719ab",
62674
+ "@settlemint/sdk-js": "1.1.16-prc78f6086",
62675
+ "@settlemint/sdk-utils": "1.1.16-prc78f6086",
62942
62676
  "@commander-js/extra-typings": "13.1.0",
62943
- commander: "13.1.0",
62944
62677
  zod: "3.24.2"
62945
62678
  },
62946
62679
  devDependencies: {},
@@ -68612,4 +68345,4 @@ main().catch((error2) => {
68612
68345
  process.exit(1);
68613
68346
  });
68614
68347
 
68615
- //# debugId=C802315A2EB302F264756E2164756E21
68348
+ //# debugId=6505AA9D00AFCA6F64756E2164756E21