MCPcopy Index your code
hub / github.com/prettier/prettier / parseArgv

Function parseArgv

src/cli/options/parse-cli-arguments.js:8–36  ·  view source on GitHub ↗
(rawArguments, detailedOptions, logger, keys)

Source from the content-addressed store, hash-verified

6import normalizeCliOptions from "./normalize-cli-options.js";
7
8function parseArgv(rawArguments, detailedOptions, logger, keys) {
9 const minimistOptions = createMinimistOptions(detailedOptions);
10 let argv = minimist(rawArguments, minimistOptions);
11
12 if (keys) {
13 detailedOptions = detailedOptions.filter((option) =>
14 keys.includes(option.name),
15 );
16 argv = pick(argv, keys);
17 }
18
19 const normalized = normalizeCliOptions(argv, detailedOptions, { logger });
20
21 return {
22 ...Object.fromEntries(
23 Object.entries(normalized).map(([key, value]) => {
24 const option = detailedOptions.find(({ name }) => name === key) || {};
25 // If the flag is a prettier API option, use the option name
26 // Otherwise use camel case for readability
27 // `--ignore-unknown` -> `ignoreUnknown`
28 return [option.forwardToApi || camelCase(key), value];
29 }),
30 ),
31 _: normalized._,
32 get __raw() {
33 return argv;
34 },
35 };
36}
37
38const { detailedOptions: detailedOptionsWithoutPlugins } =
39 getContextOptionsWithoutPlugins();

Callers 2

initMethod · 0.90
parseArgvWithoutPluginsFunction · 0.85

Calls 5

pickFunction · 0.90
createMinimistOptionsFunction · 0.85
normalizeCliOptionsFunction · 0.85
camelCaseFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…