-
-
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.
fix(command): separator option is ignored
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
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,25 @@ | ||
import { Command } from '../../lib/command.ts'; | ||
import { assertEquals } from '../lib/assert.ts'; | ||
|
||
const cmd = new Command() | ||
.throwErrors() | ||
// comma separated list | ||
.option( '-l, --list <items:number[]>', 'comma separated list of numbers.' ) | ||
// space separated list | ||
.option( '-o, --other-list <items:string[]>', 'space separated list of strings.', { separator: ' ' } ); | ||
|
||
Deno.test( 'command: list option', async () => { | ||
|
||
const { options, args } = await cmd.parse( [ '-l', '1,2,3' ] ); | ||
|
||
assertEquals( options, { list: [ 1, 2, 3 ] } ); | ||
assertEquals( args, [] ); | ||
} ); | ||
|
||
Deno.test( 'command: list option separator', async () => { | ||
|
||
const { options, args } = await cmd.parse( [ '-o', '1 2 3' ] ); | ||
|
||
assertEquals( options, { otherList: [ '1', '2', '3' ] } ); | ||
assertEquals( args, [] ); | ||
} ); |