help() — tailwindcss Function Reference
Architecture documentation for the help() function in index.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 26cfbee1_a65b_7cdd_43e1_4e9e0801f1ec["help()"] 17f8e516_5cc2_ab8d_883c_3475258793b2["println()"] 26cfbee1_a65b_7cdd_43e1_4e9e0801f1ec -->|calls| 17f8e516_5cc2_ab8d_883c_3475258793b2 3b23cd0c_5ad0_3277_32b3_47ca9425d608["header()"] 26cfbee1_a65b_7cdd_43e1_4e9e0801f1ec -->|calls| 3b23cd0c_5ad0_3277_32b3_47ca9425d608 17a9971e_bfb5_3894_9925_db391c064d8b["wordWrap()"] 26cfbee1_a65b_7cdd_43e1_4e9e0801f1ec -->|calls| 17a9971e_bfb5_3894_9925_db391c064d8b 95e53d0a_2aa1_a635_c28b_48356ee14820["indent()"] 26cfbee1_a65b_7cdd_43e1_4e9e0801f1ec -->|calls| 95e53d0a_2aa1_a635_c28b_48356ee14820 f0667321_097b_1dca_a21c_a0c318a6236a["highlight()"] 26cfbee1_a65b_7cdd_43e1_4e9e0801f1ec -->|calls| f0667321_097b_1dca_a21c_a0c318a6236a style 26cfbee1_a65b_7cdd_43e1_4e9e0801f1ec fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-upgrade/src/commands/help/index.ts lines 5–170
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 }] of Object.entries(options)) {
// 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