Skip to content

Commit

Permalink
fix: improve documentation for boolean script arguments (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m authored Mar 14, 2021
1 parent bf41381 commit 02a210b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions lib/create-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}`
: ""
} |
`;
}
);
Expand Down
2 changes: 1 addition & 1 deletion lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
]);
Expand Down

0 comments on commit 02a210b

Please sign in to comment.