From 63583f53c422c32227de6cf4650c90e7802acc84 Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 24 Jan 2024 00:55:34 -0600 Subject: [PATCH] refactor: command help --- packages/build/build/cli.js | 3 --- packages/build/build/commands.js | 8 ++++---- packages/dox/build/commands.js | 17 +++++++++-------- packages/fleck/build/commands.js | 6 +++++- packages/repl/build/commands.js | 2 +- website/docs/cli.mdx | 26 +++++++++++++------------- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/packages/build/build/cli.js b/packages/build/build/cli.js index 0b95d53..b9e5637 100755 --- a/packages/build/build/cli.js +++ b/packages/build/build/cli.js @@ -62,9 +62,6 @@ program cmd.addOption(options[i]); } cmd.action(forwardProcessCode(action)); - if (help) { - cmd.addHelpText('after', `\n${help}`); - } } // Parse commandline. program.parse(process.argv); diff --git a/packages/build/build/commands.js b/packages/build/build/commands.js index efbbcce..14dc918 100644 --- a/packages/build/build/commands.js +++ b/packages/build/build/commands.js @@ -26,7 +26,7 @@ exports.commands = (program, flecks) => { options: [ program.createOption('-d, --dev-dependency', 'add to dev dependencies'), ], - description: 'add a fleck to your application', + description: 'Add a fleck to your application.', action: async ({devDependency}, fleck) => { const args = []; if (['bun', 'yarn'].includes(packageManager)) { @@ -41,7 +41,7 @@ exports.commands = (program, flecks) => { }, }, clean: { - description: 'remove node_modules, lock file, and build artifacts', + description: 'Remove node_modules, lock file, and build artifacts.', action: () => { rimraf.sync(join(flecksRoot, 'dist')); rimraf.sync(join(flecksRoot, 'node_modules')); @@ -75,7 +75,7 @@ exports.commands = (program, flecks) => { program.createOption('-w, --watch', 'watch for changes') .implies({production: false}), ], - description: 'build a target in your application', + description: 'Build a target in your application.', action: async (target, opts) => { const { hot, @@ -104,7 +104,7 @@ exports.commands = (program, flecks) => { }; } commands.lint = { - description: 'run linter', + description: 'Run ESLint.', args: [], action: async () => { const promises = []; diff --git a/packages/dox/build/commands.js b/packages/dox/build/commands.js index cd989d8..181f4d5 100644 --- a/packages/dox/build/commands.js +++ b/packages/dox/build/commands.js @@ -22,7 +22,15 @@ module.exports = (program, flecks) => { const siteDirArgument = program.createArgument('[siteDir]', 'Docusaurus directory'); siteDirArgument.defaultValue = 'website'; commands.docusaurus = { - description: 'create a documentation website for this project', + description: [ + 'Create a documentation website for this project.', + '', + 'The `build` and `start` subcommands are sugar on top of the corresponding Docusaurus commands.', + '', + 'The `create` subcommand will create a documentation website starter template for you at `siteDir`', + "if `siteDir` doesn't already exist (defaults to `website`). A `docusaurus.config.js`", + "starter configuration will also be copied to your `build` directory if it doesn't already exist.", + ].join('\n'), action: async (subcommand, siteDir) => { const resolvedSiteDir = resolveSiteDir(siteDir); let siteDirExisted = false; @@ -79,13 +87,6 @@ module.exports = (program, flecks) => { .choices(['build', 'create', 'start']), siteDirArgument, ], - help: [ - 'The `build` and `start` subcommands are sugar on top of the corresponding Docusaurus commands.', - '', - 'The `create` subcommand will create a documentation website starter template for you at `siteDir`', - "if `siteDir` doesn't already exist (defaults to `website`). A `docusaurus.config.js`", - "starter configuration will also be copied to your `build` directory if it doesn't already exist.", - ].join('\n'), }; return commands; }; diff --git a/packages/fleck/build/commands.js b/packages/fleck/build/commands.js index ffa5057..bcafe09 100644 --- a/packages/fleck/build/commands.js +++ b/packages/fleck/build/commands.js @@ -23,7 +23,11 @@ module.exports = (program, flecks) => { program.createOption('-w, --watch', 'watch for changes'), program.createOption('-v, --verbose', 'verbose output'), ], - description: 'run tests', + description: [ + 'Run tests.', + '', + 'The options are passed along to the `build` command.', + ].join('\n'), action: async (opts) => { const { watch, diff --git a/packages/repl/build/commands.js b/packages/repl/build/commands.js index 32d4989..696b8bf 100644 --- a/packages/repl/build/commands.js +++ b/packages/repl/build/commands.js @@ -14,7 +14,7 @@ module.exports = (program, flecks) => { options: [ program.createOption('-r, --rlwrap', 'use rlwrap around socat'), ], - description: 'connect to REPL', + description: 'Connect to REPL.', action: async (opts) => { const { rlwrap, diff --git a/website/docs/cli.mdx b/website/docs/cli.mdx index 663153a..4e6430c 100644 --- a/website/docs/cli.mdx +++ b/website/docs/cli.mdx @@ -31,7 +31,7 @@ Options: ``` Usage: flecks build [options] [target] -build a target in your application +Build a target in your application. Arguments: target build target (choices: "fleck") @@ -48,7 +48,7 @@ Options: ``` Usage: flecks clean [options] -remove node_modules, lock file, and build artifacts +Remove node_modules, lock file, and build artifacts. Options: -h, --help display help for command @@ -60,7 +60,13 @@ Options: ``` Usage: flecks docusaurus [options] [siteDir] -create a documentation website for this project +Create a documentation website for this project. + +The `build` and `start` subcommands are sugar on top of the corresponding Docusaurus commands. + +The `create` subcommand will create a documentation website starter template for you at `siteDir` +if `siteDir` doesn't already exist (defaults to `website`). A `docusaurus.config.js` +starter configuration will also be copied to your `build` directory if it doesn't already exist. Arguments: subcommand Docusaurus command to run (choices: "build", "create", "start") @@ -68,12 +74,6 @@ Arguments: Options: -h, --help display help for command - -The `build` and `start` subcommands are sugar on top of the corresponding Docusaurus commands. - -The `create` subcommand will create a documentation website starter template for you at `siteDir` -if `siteDir` doesn't already exist (defaults to `website`). A `docusaurus.config.js` -starter configuration will also be copied to your `build` directory if it doesn't already exist. ``` ### `lint` @@ -81,7 +81,7 @@ starter configuration will also be copied to your `build` directory if it doesn' ``` Usage: flecks lint [options] -run linter +Run ESLint. Options: -h, --help display help for command @@ -93,7 +93,7 @@ Options: ``` Usage: flecks repl [options] -connect to REPL +Connect to REPL. Options: -r, --rlwrap use rlwrap around socat @@ -105,16 +105,16 @@ Options: ``` Usage: flecks test [options] -run tests +Run tests. Options: -d, --no-production dev build -w, --watch watch for changes -v, --verbose verbose output -h, --help display help for command -``` The options are passed along to the `build` command. +``` ## Your commands