Parses and type-converts raw CLI string arguments into typed values (boolean, number, string combos) for Tailwind CLI commands using mri.
// Source: https://github.com/tailwindlabs/tailwindcss | License: MIT | Copyright Tailwind Labs, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import parse from 'mri'
// Definition of the arguments for a command in the CLI.
export type Arg = {
[key: `--${string}`]: {
type: keyof Types
description: string
alias?: `-${string}`
default?: Types[keyof Types]
}
}
// Each argument will have a type and we want to convert the incoming raw string
// based value to the correct type. We can't use pure TypeScript types because
// these don't exist at runtime. Instead, we define a string-based type that
// maps to a TypeScript type.
type Types = {
boolean: boolean
number: number | null
string: string | null
'boolean | string': boolean | string | null
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key