()
| 214 | } |
| 215 | |
| 216 | function getHelp() { |
| 217 | const options = [ |
| 218 | { flags: '-h, --help', description: 'Display this help message.' }, |
| 219 | { flags: '-t, --template NAME', description: 'Use a specific template.' }, |
| 220 | { flags: '--no-telemetry', description: 'Disable anonymous usage tracking.' }, |
| 221 | ] |
| 222 | |
| 223 | const GAP_SIZE = 2 |
| 224 | const optionPrefix = ' ' |
| 225 | const templatePrefix = ' • ' |
| 226 | |
| 227 | const idealIndentSize = |
| 228 | Math.max( |
| 229 | ...options.map((o) => o.flags.length), |
| 230 | ...TEMPLATES.map((t) => formatTemplateId(t).length) |
| 231 | ) + |
| 232 | GAP_SIZE + |
| 233 | templatePrefix.length |
| 234 | |
| 235 | const isNarrow = process.stdout.columns < idealIndentSize + 50 |
| 236 | |
| 237 | const lines = [ |
| 238 | picocolors.bold('Usage: create-tldraw [OPTION]... [DIRECTORY]'), |
| 239 | '', |
| 240 | 'Create a new tldraw project from a starter kit.', |
| 241 | "With no arguments, you'll be guided through an interactive setup.", |
| 242 | '', |
| 243 | picocolors.bold('Options:'), |
| 244 | ] |
| 245 | |
| 246 | if (isNarrow) { |
| 247 | const indent = ' '.repeat(optionPrefix.length + GAP_SIZE) |
| 248 | for (const option of options) { |
| 249 | lines.push(`${optionPrefix}${option.flags}`) |
| 250 | lines.push(wrapAnsi(`${indent}${option.description}`, process.stdout.columns, { indent })) |
| 251 | } |
| 252 | } else { |
| 253 | const indent = ' '.repeat(idealIndentSize) |
| 254 | for (const option of options) { |
| 255 | const start = `${optionPrefix}${option.flags}`.padEnd(idealIndentSize, ' ') |
| 256 | lines.push(wrapAnsi(`${start}${option.description}`, process.stdout.columns, { indent })) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | lines.push('') |
| 261 | lines.push(picocolors.bold('Available starter kits:')) |
| 262 | |
| 263 | if (isNarrow) { |
| 264 | const indent = ' '.repeat(templatePrefix.length + GAP_SIZE) |
| 265 | for (const template of TEMPLATES) { |
| 266 | lines.push(`${templatePrefix}${formatTemplateId(template)}`) |
| 267 | lines.push( |
| 268 | wrapAnsi( |
| 269 | `${indent}${template.shortDescription ?? template.description}`, |
| 270 | process.stdout.columns, |
| 271 | { indent } |
| 272 | ) |
| 273 | ) |
no test coverage detected
searching dependent graphs…