Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust help text to new style guide #259

Merged
merged 2 commits into from
Sep 27, 2021
Merged
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
6 changes: 1 addition & 5 deletions src/config/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ export class Plugin implements IPlugin {
this.manifest = await this._manifest(Boolean(this.options.ignoreManifest), Boolean(this.options.errorOnManifestCreate))
this.commands = Object.entries(this.manifest.commands)
.map(([id, c]) => ({...c, pluginAlias: this.alias, pluginType: this.type, load: async () => this.findCommand(id, {must: true})}))
this.commands.sort((a, b) => {
if (a.id < b.id) return -1
if (a.id > b.id) return 1
return 0
})
this.commands.sort((a, b) => a.id.localeCompare(b.id))
}

get topics(): Topic[] {
Expand Down
4 changes: 2 additions & 2 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export {boolean, integer, url} from './parser'

export const version = (opts: Partial<BooleanFlag<boolean>> = {}) => {
return Parser.flags.boolean({
description: 'show CLI version',
description: 'Show CLI version.',
...opts,
parse: async (_: any, cmd: Command) => {
cmd.log(cmd.config.userAgent)
Expand All @@ -42,7 +42,7 @@ export const version = (opts: Partial<BooleanFlag<boolean>> = {}) => {

export const help = (opts: Partial<BooleanFlag<boolean>> = {}) => {
return Parser.flags.boolean({
description: 'show CLI help',
description: 'Show CLI help.',
...opts,
parse: async (_: any, cmd: Command) => {
(cmd as any)._help()
Expand Down
2 changes: 1 addition & 1 deletion src/help/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class Help extends HelpBase {
return
}

error(`command ${subject} not found`)
error(`Command ${subject} not found.`)
}

public async showCommandHelp(command: Interfaces.Command) {
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {fileURLToPath} from 'url'
import {format, inspect} from 'util'

import * as Interfaces from './interfaces'
import {URL} from 'url'
import {Config} from './config'
import {getHelpFlagAdditions, loadHelpClass, standardizeIDFromArgv} from './help'

Expand Down Expand Up @@ -33,7 +34,7 @@ export const versionAddition = (argv: string[], config?: Interfaces.Config): boo
// eslint-disable-next-line default-param-last
export async function run(argv = process.argv.slice(2), options?: Interfaces.LoadOptions) {
// Handle the case when a file URL string or URL is passed in such as 'import.meta.url'; covert to file path.
if ((typeof options === 'string' && options.startsWith('file://')) || options instanceof URL) {
if (options && ((typeof options === 'string' && options.startsWith('file://')) || options instanceof URL)) {
options = fileURLToPath(options)
}

Expand Down
2 changes: 1 addition & 1 deletion test/help/show-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('showHelp routing', () => {
test
.setupHelp()
.it('shows an error when there is a subject but it does not match a topic or command', async ({help}) => {
await expect(help.showHelp(['meow'])).to.be.rejectedWith('command meow not found')
await expect(help.showHelp(['meow'])).to.be.rejectedWith('Command meow not found')
})
})
})
2 changes: 2 additions & 0 deletions test/parser/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {expect} from 'chai'

import {flags, parse} from '../../src/parser'
import {Interfaces} from '../../src'
import {URL} from 'url'

const stripAnsi = require('strip-ansi')

describe('parse', () => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"./src"
],
"strict": true,
"target": "es2017"
"target": "es2019",
"lib": ["es2019"]
},
"include": [
"./src/**/*"
Expand Down