Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mdonnalley/flag-relationships
- Loading branch information
Showing
13 changed files
with
596 additions
and
130 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
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,33 @@ | ||
import {FlagInput} from './parser' | ||
|
||
/** | ||
* Infer the flags that are returned by Command.parse. This is useful for when you want to assign the flags as a class property. | ||
* | ||
* @example | ||
* export type StatusFlags = Interfaces.InferredFlags<typeof Status.flags & typeof Status.globalFlags> | ||
* | ||
* export abstract class BaseCommand extends Command { | ||
* static enableJsonFlag = true | ||
* | ||
* static globalFlags = { | ||
* config: Flags.string({ | ||
* description: 'specify config file', | ||
* }), | ||
* } | ||
* } | ||
* | ||
* export default class Status extends BaseCommand { | ||
* static flags = { | ||
* force: Flags.boolean({char: 'f', description: 'a flag'}), | ||
* } | ||
* | ||
* public flags!: StatusFlags | ||
* | ||
* public async run(): Promise<StatusFlags> { | ||
* const result = await this.parse(Status) | ||
* this.flags = result.flags | ||
* return result.flags | ||
* } | ||
* } | ||
*/ | ||
export type InferredFlags<T> = T extends FlagInput<infer F> ? F & { json: boolean | undefined; } : unknown |
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
Oops, something went wrong.