Home / Function/ args() — tailwindcss Function Reference

args() — tailwindcss Function Reference

Architecture documentation for the args() function in args.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  e9feacff_172e_20e8_5e0f_c6ccfd22ac0e["args()"]
  9bf716c1_a944_1eb2_180b_5c0151e992ba["args.ts"]
  e9feacff_172e_20e8_5e0f_c6ccfd22ac0e -->|defined in| 9bf716c1_a944_1eb2_180b_5c0151e992ba
  0d3484ba_902a_102a_0d5b_4d5f96e46062["convert()"]
  e9feacff_172e_20e8_5e0f_c6ccfd22ac0e -->|calls| 0d3484ba_902a_102a_0d5b_4d5f96e46062
  style e9feacff_172e_20e8_5e0f_c6ccfd22ac0e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-cli/src/utils/args.ts lines 70–122

export function args<const T extends Arg>(options: T, argv = process.argv.slice(2)): Result<T> {
  for (let [idx, value] of argv.entries()) {
    if (value === '-') {
      argv[idx] = '__IO_DEFAULT_VALUE__'
    }
  }

  let parsed = parse(argv)

  for (let key in parsed) {
    let value = parsed[key]

    if (key !== '_' && Array.isArray(value)) {
      value = value[value.length - 1]
    }

    if (value === '__IO_DEFAULT_VALUE__') {
      value = '-'
    }

    parsed[key] = value
  }

  let result: { _: string[]; [key: string]: unknown } = {
    _: parsed._,
  }

  for (let [
    flag,
    { type, alias, default: defaultValue = type === 'boolean' ? false : null },
  ] of Object.entries(options)) {
    // Start with the default value
    result[flag] = defaultValue

    // Try to find the `alias`, and map it to long form `flag`
    if (alias) {
      let key = alias.slice(1)
      if (parsed[key] !== undefined) {
        result[flag] = convert(parsed[key], type)
      }
    }

    // Try to find the long form `flag`
    {
      let key = flag.slice(2)
      if (parsed[key] !== undefined) {
        result[flag] = convert(parsed[key], type)
      }
    }
  }

  return result as Result<T>
}

Subdomains

Calls

Frequently Asked Questions

What does args() do?
args() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-cli/src/utils/args.ts.
Where is args() defined?
args() is defined in packages/@tailwindcss-cli/src/utils/args.ts at line 70.
What does args() call?
args() calls 1 function(s): convert.

Analyze Your Own Codebase

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

Try Supermodel Free