help() — tailwindcss Function Reference
Architecture documentation for the help() function in index.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD b53ee5b3_ea99_2734_8356_c51cb2541f61["help()"] afc096a3_8c82_b179_2f3f_4f0d8b7ac88d["println()"] b53ee5b3_ea99_2734_8356_c51cb2541f61 -->|calls| afc096a3_8c82_b179_2f3f_4f0d8b7ac88d d325b2d7_3798_071e_9367_51571b6510df["header()"] b53ee5b3_ea99_2734_8356_c51cb2541f61 -->|calls| d325b2d7_3798_071e_9367_51571b6510df 6228667b_758c_4d4c_8d69_6e8bafcbaef9["wordWrap()"] b53ee5b3_ea99_2734_8356_c51cb2541f61 -->|calls| 6228667b_758c_4d4c_8d69_6e8bafcbaef9 8f42f953_58d4_334b_93ad_8e9a7e09498b["indent()"] b53ee5b3_ea99_2734_8356_c51cb2541f61 -->|calls| 8f42f953_58d4_334b_93ad_8e9a7e09498b cb9bcb03_3ce2_399c_0223_7430307351b4["highlight()"] b53ee5b3_ea99_2734_8356_c51cb2541f61 -->|calls| cb9bcb03_3ce2_399c_0223_7430307351b4 style b53ee5b3_ea99_2734_8356_c51cb2541f61 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-cli/src/commands/help/index.ts lines 5–174
export function help({
invalid,
usage,
options,
}: {
invalid?: string
usage?: string[]
options?: Arg
}) {
// Available terminal width
let width = process.stdout.columns
// Render header
println(header())
// Render the invalid command
if (invalid) {
println()
println(`${pc.dim('Invalid command:')} ${invalid}`)
}
// Render usage
if (usage && usage.length > 0) {
println()
println(pc.dim('Usage:'))
for (let [idx, example] of usage.entries()) {
// Split the usage example into the command and its options. This allows
// us to wrap the options based on the available width of the terminal.
let command = example.slice(0, example.indexOf('['))
let options = example.slice(example.indexOf('['))
// Make the options dimmed, to make them stand out less than the command
// itself.
options = options.replace(/\[.*?\]/g, (option) => pc.dim(option))
// The space between the command and the options.
let space = 1
// Wrap the options based on the available width of the terminal.
let lines = wordWrap(options, width - UI.indent - command.length - space)
// Print an empty line between the usage examples if we need to split due
// to width constraints. This ensures that the usage examples are visually
// separated.
//
// E.g.: when enough space is available
//
// ```
// Usage:
// tailwindcss build [--input input.css] [--output output.css] [--watch] [options...]
// tailwindcss other [--watch] [options...]
// ```
//
// E.g.: when not enough space is available
//
// ```
// Usage:
// tailwindcss build [--input input.css] [--output output.css]
// [--watch] [options...]
//
// tailwindcss other [--watch] [options...]
// ```
if (lines.length > 1 && idx !== 0) {
println()
}
// Print the usage examples based on available width of the terminal.
//
// E.g.: when enough space is available
//
// ```
// Usage:
// tailwindcss [--input input.css] [--output output.css] [--watch] [options...]
// ```
//
// E.g.: when not enough space is available
//
// ```
// Usage:
// tailwindcss [--input input.css] [--output output.css]
// [--watch] [options...]
// ```
//
// > Note how the second line is indented to align with the first line.
println(indent(`${command}${lines.shift()}`))
for (let line of lines) {
println(indent(line, command.length))
}
}
}
// Render options
if (options) {
// Track the max alias length, this is used to indent the options that don't
// have an alias such that everything is aligned properly.
let maxAliasLength = 0
for (let { alias } of Object.values(options)) {
if (alias) {
maxAliasLength = Math.max(maxAliasLength, alias.length)
}
}
// The option strings, which are the combination of the `alias` and the
// `flag`, with the correct spacing.
let optionStrings: string[] = []
// Track the max option length, which is the longest combination of an
// `alias` followed by `, ` and followed by the `flag`.
let maxOptionLength = 0
for (let [flag, { alias, values }] of Object.entries(options)) {
if (values?.length) {
flag += `[=${values.join(', ')}]`
}
// The option string, which is the combination of the alias and the flag
// but already properly indented based on the other aliases to ensure
// everything is aligned properly.
let option = [
alias ? `${alias.padStart(maxAliasLength)}` : alias,
alias ? flag : ' '.repeat(maxAliasLength + 2 /* `, `.length */) + flag,
]
.filter(Boolean)
.join(', ')
optionStrings.push(option)
maxOptionLength = Math.max(maxOptionLength, option.length)
}
println()
println(pc.dim('Options:'))
// The minimum amount of dots between the option and the description.
let minimumGap = 8
for (let { description, default: defaultValue = null } of Object.values(options)) {
// The option to render
let option = optionStrings.shift() as string
// The amount of dots to show between the option and the description.
let dotCount = minimumGap + (maxOptionLength - option.length)
// To account for the space before and after the dots.
let spaces = 2
// The available width remaining for the description.
let availableWidth = width - option.length - dotCount - spaces - UI.indent
// Wrap the description and the default value (if present), based on the
// available width.
let lines = wordWrap(
defaultValue !== null
? `${description} ${pc.dim(`[default:\u202F${highlight(`${defaultValue}`)}]`)}`
: description,
availableWidth,
)
// Print the option, the spacer dots and the start of the description.
println(
indent(`${pc.blue(option)} ${pc.dim(pc.gray('\u00B7')).repeat(dotCount)} ${lines.shift()}`),
)
// Print the remaining lines of the description, indenting them to align
// with the start of the description.
for (let line of lines) {
println(indent(`${' '.repeat(option.length + dotCount + spaces)}${line}`))
}
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does help() do?
help() is a function in the tailwindcss codebase.
What does help() call?
help() calls 5 function(s): header, highlight, indent, println, wordWrap.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free