MCPcopy
hub / github.com/tailwindlabs/tailwindcss / args

Function args

packages/@tailwindcss-upgrade/src/utils/args.ts:69–101  ·  packages/@tailwindcss-upgrade/src/utils/args.ts::args
(options: T, argv = process.argv.slice(2))

Source from the content-addressed store, hash-verified

67}
68
69export function args<const T extends Arg>(options: T, argv = process.argv.slice(2)): Result<T> {
70 let parsed = parse(argv)
71
72 let result: { _: string[]; [key: string]: unknown } = {
73 _: parsed._,
74 }
75
76 for (let [
77 flag,
78 { type, alias, default: defaultValue = type === class="st">'boolean' ? false : null },
79 ] of Object.entries(options)) {
80 class="cm">// Start with the default value
81 result[flag] = defaultValue
82
83 class="cm">// Try to find the `alias`, and map it to long form `flag`
84 if (alias) {
85 let key = alias.slice(1)
86 if (parsed[key] !== undefined) {
87 result[flag] = convert(parsed[key], type)
88 }
89 }
90
91 class="cm">// Try to find the long form `flag`
92 {
93 let key = flag.slice(2)
94 if (parsed[key] !== undefined) {
95 result[flag] = convert(parsed[key], type)
96 }
97 }
98 }
99
100 return result as Result<T>
101}
102
103class="cm">// ---
104

Callers 2

index.tsFile · 0.90
args.test.tsFile · 0.90

Calls 3

convertFunction · 0.70
parseFunction · 0.50
entriesMethod · 0.45

Tested by

no test coverage detected