Home / File/ args.ts — tailwindcss Source File

args.ts — tailwindcss Source File

Architecture documentation for args.ts, a typescript file in the tailwindcss codebase. 1 imports, 3 dependents.

File typescript CommandLineInterface Renderer 1 imports 3 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  f680db01_c2c6_090b_99ee_9df802d112b2["args.ts"]
  8b64655b_3d1d_9a5d_60bb_5ae3b37e41e9["mri"]
  f680db01_c2c6_090b_99ee_9df802d112b2 --> 8b64655b_3d1d_9a5d_60bb_5ae3b37e41e9
  dedd6830_c180_a2b0_01d1_b5874e938eb8["index.ts"]
  dedd6830_c180_a2b0_01d1_b5874e938eb8 --> f680db01_c2c6_090b_99ee_9df802d112b2
  2e62a025_c320_60cb_6b4c_aa1efeed2ed9["index.ts"]
  2e62a025_c320_60cb_6b4c_aa1efeed2ed9 --> f680db01_c2c6_090b_99ee_9df802d112b2
  7e8f1331_e824_8a13_f1ad_47710a6fb07e["args.test.ts"]
  7e8f1331_e824_8a13_f1ad_47710a6fb07e --> f680db01_c2c6_090b_99ee_9df802d112b2
  style f680db01_c2c6_090b_99ee_9df802d112b2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source 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]
    values?: string[]
  }
}

// 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
  'number | string': number | string | null
  'boolean | number': boolean | number | null
  'boolean | number | string': boolean | number | string | null
}

// Convert the `Arg` type to a type that can be used at runtime.
//
// E.g.:
//
// Arg:
// ```
// { '--input': { type: 'string', description: 'Input file', alias: '-i' } }
// ```
//
// Command:
// ```
// ./tailwindcss -i input.css
// ./tailwindcss --input input.css
// ```
//
// Result type:
// ```
// {
//   _: string[],             // All non-flag arguments
//   '--input': string | null // The `--input` flag will be filled with `null`, if the flag is not used.
//                            // The `null` type will not be there if `default` is provided.
// }
// ```
//
// Result runtime object:
// ```
// {
//   _: [],
//   '--input': 'input.css'
// }
// ```
export type Result<T extends Arg> = {
  [K in keyof T]: T[K] extends { type: keyof Types; default?: any }
// ... (122 more lines)

Subdomains

Dependencies

  • mri

Frequently Asked Questions

What does args.ts do?
args.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Renderer subdomain.
What functions are defined in args.ts?
args.ts defines 5 function(s): args, convert, convertBoolean, convertNumber, convertString.
What does args.ts depend on?
args.ts imports 1 module(s): mri.
What files import args.ts?
args.ts is imported by 3 file(s): args.test.ts, index.ts, index.ts.
Where is args.ts in the architecture?
args.ts is located at packages/@tailwindcss-cli/src/utils/args.ts (domain: CommandLineInterface, subdomain: Renderer, directory: packages/@tailwindcss-cli/src/utils).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free