This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for readme-generation with custom help
Co-authored-by: Chad Carbert <chadcarbert@me.com>
- Loading branch information
Showing
8 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This a test help class for the purposes of dev-cli and readme generation. | ||
// It is used for testing purposes only as the dev-cli generates a readme for itself in tests | ||
// (see readme tests). For more info on help plugins check out @oclif/plugin-help | ||
|
||
export default class TestHelp { | ||
[x: string]: any | ||
|
||
getCommandHelpForReadme(command: any) { | ||
const flags = Object.keys(command.flags).join(', ') | ||
return `Test help generated by test plugin for: ${command.id}\nIt has the following flags: ${flags}` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# cli-with-custom-help | ||
|
||
This file is a test for running `oclif-dev readme` in the presence of | ||
a custom help class. It should use the custom help class to generate | ||
the command documentation below. The test suite resets this file after | ||
each test. | ||
|
||
<!-- toc --> | ||
<!-- tocstop --> | ||
|
||
# Usage | ||
|
||
<!-- usage --> | ||
<!-- usagestop --> | ||
|
||
# Commands | ||
|
||
<!-- commands --> | ||
<!-- commandsstop --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "cli-with-custom-help", | ||
"files": [ | ||
"/lib" | ||
], | ||
"oclif": { | ||
"commands": "./lib/commands", | ||
"bin": "cli-with-custom-help", | ||
"helpClass": "./lib/help" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {Command, flags} from '@oclif/command' | ||
|
||
export default class Hello extends Command { | ||
static description = 'describe the command here' | ||
|
||
static examples = [ | ||
`$ cli-with-custom-help hello | ||
hello world from ./src/hello.ts! | ||
`, | ||
] | ||
|
||
static flags = { | ||
help: flags.help({char: 'h'}), | ||
// flag with a value (-n, --name=VALUE) | ||
name: flags.string({char: 'n', description: 'name to print'}), | ||
// flag with no value (-f, --force) | ||
force: flags.boolean({char: 'f'}), | ||
} | ||
|
||
static args = [{name: 'file'}] | ||
|
||
async run() { | ||
const {args, flags} = this.parse(Hello) | ||
|
||
const name = flags.name ?? 'world' | ||
this.log(`hello ${name} from ./src/commands/hello.ts`) | ||
if (args.file && flags.force) { | ||
this.log(`you input --force and --file: ${args.file}`) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {HelpBase} from '@oclif/plugin-help' | ||
import {Command} from '@oclif/config' | ||
|
||
export default class CustomHelp extends HelpBase { | ||
showHelp() { | ||
console.log('TODO: showHelp') | ||
} | ||
|
||
showCommandHelp(command: Command) { | ||
console.log(`Custom help for ${command.id}`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {run} from '@oclif/command' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"importHelpers": true, | ||
"module": "commonjs", | ||
"outDir": "lib", | ||
"rootDir": "src", | ||
"strict": true, | ||
"target": "es2017" | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters