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 custom type class's
- Loading branch information
Showing
5 changed files
with
67 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { IFlagArgument, IFlagOptions } from '../../flags/lib/types.ts'; | ||
import { boolean } from '../../flags/lib/types/boolean.ts'; | ||
import { Type } from './type.ts'; | ||
|
||
export class BooleanType extends Type<boolean> { | ||
|
||
public parse( option: IFlagOptions, arg: IFlagArgument, value: string | false ): boolean | undefined { | ||
|
||
return boolean( option, arg, value ); | ||
} | ||
} |
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 @@ | ||
import { IFlagArgument, IFlagOptions } from '../../flags/lib/types.ts'; | ||
import { number } from '../../flags/lib/types/number.ts'; | ||
import { Type } from './type.ts'; | ||
|
||
export class NumberType extends Type<number> { | ||
|
||
public parse( option: IFlagOptions, arg: IFlagArgument, value: string | false ): number | undefined { | ||
|
||
return number( option, arg, value ); | ||
} | ||
} |
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 @@ | ||
import { IFlagArgument, IFlagOptions } from '../../flags/lib/types.ts'; | ||
import { string } from '../../flags/lib/types/string.ts'; | ||
import { Type } from './type.ts'; | ||
|
||
export class StringType extends Type<string> { | ||
|
||
public parse( option: IFlagOptions, arg: IFlagArgument, value: string | false ): string | undefined { | ||
|
||
return string( option, arg, value ); | ||
} | ||
} |
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,6 @@ | ||
import { IFlagArgument, IFlagOptions } from '../../flags/lib/types.ts'; | ||
|
||
export abstract class Type<T> { | ||
|
||
public abstract parse( option: IFlagOptions, arg: IFlagArgument, value: string | false ): T | undefined | ||
} |