How to use the InvalidOptionArgumentError function from commander

Find comprehensive JavaScript commander.InvalidOptionArgumentError code examples handpicked from public code repositorys.

243
244
245
246
247
248
249
250
251
252
253
};


// Provide the CLI
_commander.program.version(_package.version).description('Start a server to render Mapbox GL map requests to images.').option('-p, --port <n>', 'Server port', parseInt).option('-t, --tiles <mbtiles_path>', 'Directory containing local mbtiles files to render', function (tilePath) {
  if (!_fs["default"].existsSync(tilePath)) {
    throw new _commander.InvalidOptionArgumentError("Path to mbtiles files does not exist: ".concat(tilePath));
  }
  return tilePath;
}).option('-v, --verbose', 'Enable request logging').parse(process.argv);
var _program$opts = _commander.program.opts(),
fork icon56
star icon174
watch icon12

+ 3 other calls in file

21
22
23
24
25
26
27
28
29
30
 * component name, otherwise throws an error.
 * @param {string} value - component name
 */
function validateComponentName(value) {
  if (!/^([A-Z][a-z]*)([A-Z][a-z]*)*$/g.test(value)) {
    throw new InvalidOptionArgumentError('Name should match Pascal case. Example: MyComponent.');
  }
  if (fs.existsSync(path.resolve(__dirname, `../src/${value}`))) {
    throw new InvalidOptionArgumentError('The component already exists.');
  }
fork icon43
star icon89
watch icon73

+ 3 other calls in file

137
138
139
140
141
142
143
144
145

/** @param {string} value */
function parseOptPort (value) {
  const num = +value;
  if (num < 1024 || num > 49151) {
    throw new program.InvalidOptionArgumentError('Port must be between 1024-49151.');
  }
  return num;
}
fork icon6
star icon2
watch icon2

+ 11 other calls in file

92
93
94
95
96
97
98
99
100
101
  theme = themeOrPath
} else {
  theme = loadM8FileAndVerify(themeOrPath)

  if (theme.constructor.name !== 'Theme') {
    throw new commander.InvalidOptionArgumentError("option '-T, --theme <path>' must be to an M8 Theme file")
  }
}

m8Text.default = clc.xterm(x256(theme.textDefault.r, theme.textDefault.g, theme.textDefault.b))
fork icon1
star icon29
watch icon0

+ 39 other calls in file

13
14
15
16
17
18
19
20
21
22
23
}


function validateTicker(ticker) {
  const key = ticker.toUpperCase();
  if (QUESTIONS[0].choices.includes(key) === false) {
    throw new InvalidOptionArgumentError("Not a valid crypto ticker.");
  }
  return key;
}

fork icon0
star icon0
watch icon1

+ 91 other calls in file

49
50
51
52
53
54
55
56
57
58
59
60
      throw new InvalidOptionArgumentError(`Could not parse url ${value}`);
    }


    return url;
  } catch (e) {
    throw new InvalidOptionArgumentError(`Could not parse url ${value}`);
  }
};


/**
fork icon0
star icon0
watch icon1

+ 15 other calls in file

45
46
47
48
49
50
51
52
53
54
 */
const parseInteger = (value) => {
  // parseInt takes a string and a radix
  const parsedValue = parseInt(value, 10);
  if (isNaN(parsedValue)) {
    throw new InvalidOptionArgumentError(`Not an integer: ${value}`);
  }
  return parsedValue;
};

fork icon0
star icon0
watch icon654

+ 11 other calls in file

Other functions in commander

Sorted by popularity

function icon

commander.Option is the most popular function in commander (1786 examples)