From 02a210b502ea8904190a4c05181f990d9125298d Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Sun, 14 Mar 2021 13:54:54 -0700 Subject: [PATCH] fix: improve documentation for boolean script arguments (#21) --- lib/create-readme.js | 20 +++++++++++++++++--- lib/prompts.js | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/create-readme.js b/lib/create-readme.js index 12514c2..d6cf638 100644 --- a/lib/create-readme.js +++ b/lib/create-readme.js @@ -67,10 +67,24 @@ ${usage} `; Object.entries(scriptOptions).forEach( - ([name, { type, required, description }]) => { - content += `| \`--${decamelize(name, { + ([name, { type, required, description, default: defaultValue }]) => { + const CliOption = decamelize(name, { separator: "-", - })}\` | ${type} | ${required ? `**(required)**` : ""} ${description} | + }); + let optionNames = `\`--${CliOption}\``; + if (type === "boolean") { + optionNames += ` or \`--no-${CliOption}\``; + } + + content += `| ${optionNames} | ${type} | ${ + required ? `**(required)**` : "" + } ${description} ${ + defaultValue + ? `. Defaults to ${ + type === "string" ? `"${defaultValue}"` : defaultValue + }` + : "" + } | `; } ); diff --git a/lib/prompts.js b/lib/prompts.js index f9865e0..8773124 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -142,7 +142,7 @@ export default async function prompts({ { type: "input", name: "path", - message: `Folder path to initialize the project in, relative to current path. If the path it does not yet exist it will be created. Current path is ${process.cwd()})`, + message: `Folder path to initialize the project in, relative to current path. If the path does not yet exist it will be created. Current path is ${process.cwd()})`, default: () => answers1.repository.split("/")[1], }, ]);