Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
const path = require('node:path')
const commist = require('commist')()
const { parseArgs } = require('node:util')
const argv = parseArgs({ args: process.argv.slice(2), strict: false, allowPositionals: true }).values
const parsedArgs = parseArgs({ args: process.argv.slice(2), strict: false, allowPositionals: true })
const argv = parsedArgs.values
const help = require('help-me')({
// the default
dir: path.join(path.dirname(require.main.filename), 'help')
Expand All @@ -32,7 +33,7 @@ commist.register('print-routes', printRoutes.cli)
commist.register('print-plugins', printPlugins.cli)

if (argv.help) {
const command = argv._.splice(2)[0]
const command = parsedArgs.positionals[0]

help.toStdout(command)
} else {
Expand Down
7 changes: 7 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ test('--help', async t => {
)
})

test('--help generate', async t => {
t.assert.equal(
execSync('node cli.js --help generate', { encoding: 'utf-8' }),
readFileSync(path.join(__dirname, '../help/generate.txt'), 'utf-8')
)
})

test('generate --help', async t => {
t.assert.equal(
execSync('node cli.js generate --help', { encoding: 'utf-8' }),
Expand Down
Loading