-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(command): add support for hidden options's #23
- Loading branch information
Showing
3 changed files
with
61 additions
and
5 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
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
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,47 @@ | ||
import { stripeColors } from '../../../table/lib/utils.ts'; | ||
import { Command } from '../../lib/command.ts'; | ||
import { assertEquals } from '../lib/assert.ts'; | ||
|
||
function command(): Command { | ||
return new Command() | ||
.throwErrors() | ||
.version( '1.0.0' ) | ||
.description( 'Test description ...' ) | ||
.option( '-h, --hidden <value:string>', 'Nobody knows about me!', { hidden: true } ) | ||
.hidden(); | ||
} | ||
|
||
Deno.test( 'hidden option', async () => { | ||
|
||
const cmd: Command = command(); | ||
const { options, args } = await cmd.parse( [ '--hidden', 'test' ] ); | ||
|
||
assertEquals( options, { hidden: 'test' } ); | ||
assertEquals( args, [] ); | ||
} ); | ||
|
||
Deno.test( 'hidden option help', async () => { | ||
|
||
const cmd: Command = command(); | ||
const output: string = cmd.getHelpCommand().getHelp(); | ||
|
||
assertEquals( stripeColors( output ), ` | ||
Usage: COMMAND | ||
Version: v1.0.0 | ||
Description: | ||
Test description ... | ||
Options: | ||
-h, --help [arg:boolean] - Show this help. | ||
-V, --version [arg:boolean] - Show the version number for this program. | ||
Commands: | ||
help [command:command] - Show this help or the help of a sub-command. | ||
completions - Generate shell completions for zsh and bash. | ||
` ); | ||
} ); |