@oclif/core 2.0.3 → 2.0.4

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.
@@ -49,6 +49,9 @@ const readStdin = async () => {
49
49
  }, { once: true });
50
50
  });
51
51
  };
52
+ function isNegativeNumber(input) {
53
+ return /^-\d/g.test(input);
54
+ }
52
55
  class Parser {
53
56
  constructor(input) {
54
57
  this.input = input;
@@ -137,7 +140,7 @@ class Parser {
137
140
  dashdash = true;
138
141
  continue;
139
142
  }
140
- if (this.input['--'] !== false) {
143
+ if (this.input['--'] !== false && !isNegativeNumber(input)) {
141
144
  // At this point we have a value that begins with '-' or '--'
142
145
  // but doesn't match up to a flag definition. So we assume that
143
146
  // this is a misspelled flag or a non-existent flag,
@@ -193,7 +196,7 @@ class Parser {
193
196
  flags[token.flag].push(...values);
194
197
  }
195
198
  else {
196
- const value = flag.parse ? await flag.parse(input, this.context, flag) : input;
199
+ const value = await this._parseFlag(input, flag);
197
200
  if (flag.multiple) {
198
201
  flags[token.flag] = flags[token.flag] || [];
199
202
  flags[token.flag].push(value);
@@ -213,7 +216,7 @@ class Parser {
213
216
  if (flag.type === 'option') {
214
217
  if (input) {
215
218
  this._validateOptions(flag, input);
216
- flags[k] = await flag.parse(input, this.context, flag);
219
+ flags[k] = await this._parseFlag(input, flag);
217
220
  }
218
221
  }
219
222
  else if (flag.type === 'boolean') {
@@ -230,6 +233,8 @@ class Parser {
230
233
  return flags;
231
234
  }
232
235
  async _parseFlag(input, flag) {
236
+ if (!flag.parse)
237
+ return input;
233
238
  try {
234
239
  if (flag.type === 'boolean') {
235
240
  return await flag.parse(input, this.context, flag);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "2.0.3",
4
+ "version": "2.0.4",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {