MCPcopy
hub / github.com/tailwindlabs/tailwindcss / help

Function help

packages/@tailwindcss-upgrade/src/commands/help/index.ts:5–170  ·  view source on GitHub ↗
({
  invalid,
  usage,
  options,
}: {
  invalid?: string
  usage?: string[]
  options?: Arg
})

Source from the content-addressed store, hash-verified

3import { UI, header, highlight, indent, println, wordWrap } from '../../utils/renderer'
4
5export function help({
6 invalid,
7 usage,
8 options,
9}: {
10 invalid?: string
11 usage?: string[]
12 options?: Arg
13}) {
14 // Available terminal width
15 let width = process.stdout.columns
16
17 // Render header
18 println(header())
19
20 // Render the invalid command
21 if (invalid) {
22 println()
23 println(`${pc.dim('Invalid command:')} ${invalid}`)
24 }
25
26 // Render usage
27 if (usage && usage.length > 0) {
28 println()
29 println(pc.dim('Usage:'))
30 for (let [idx, example] of usage.entries()) {
31 // Split the usage example into the command and its options. This allows
32 // us to wrap the options based on the available width of the terminal.
33 let command = example.slice(0, example.indexOf('['))
34 let options = example.slice(example.indexOf('['))
35
36 // Make the options dimmed, to make them stand out less than the command
37 // itself.
38 options = options.replace(/\[.*?\]/g, (option) => pc.dim(option))
39
40 // The space between the command and the options.
41 let space = 1
42
43 // Wrap the options based on the available width of the terminal.
44 let lines = wordWrap(options, width - UI.indent - command.length - space)
45
46 // Print an empty line between the usage examples if we need to split due
47 // to width constraints. This ensures that the usage examples are visually
48 // separated.
49 //
50 // E.g.: when enough space is available
51 //
52 // ```
53 // Usage:
54 // tailwindcss build [--input input.css] [--output output.css] [--watch] [options...]
55 // tailwindcss other [--watch] [options...]
56 // ```
57 //
58 // E.g.: when not enough space is available
59 //
60 // ```
61 // Usage:
62 // tailwindcss build [--input input.css] [--output output.css]

Callers 1

index.tsFile · 0.90

Calls 6

printlnFunction · 0.90
headerFunction · 0.90
wordWrapFunction · 0.90
indentFunction · 0.90
highlightFunction · 0.90
entriesMethod · 0.45

Tested by

no test coverage detected