-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,827 additions
and
1,650 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,11 @@ | ||
import { Command } from '../index.js'; | ||
|
||
// Example of strongly typed globals in a subcommand which is added to program using .addCommand(). | ||
// Declare factory function for root Command in separate file from adding subcommands to avoid circular dependencies. | ||
|
||
export function createProgram() { | ||
const program = new Command().option('-g, --global'); | ||
return program; | ||
} | ||
|
||
export type ProgramOpts = ReturnType<ReturnType<typeof createProgram>['opts']>; |
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 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-object-type */ | ||
|
||
// Example of strongly typed globals in a subcommand which is added to program using .addCommand(). | ||
|
||
import { Command } from '../index.js'; | ||
import { type ProgramOpts } from './assemble-program.js'; | ||
|
||
export function createSub() { | ||
const program = new Command<[], {}, ProgramOpts>('sub').option('-l, --local'); | ||
const optsWithGlobals = program.optsWithGlobals(); | ||
return program; | ||
} | ||
|
||
export type SubOpts = ReturnType<typeof createSub>['opts']; |
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 { createProgram, type ProgramOpts } from './assemble-program'; | ||
import { createSub, type SubOpts } from './assemble-sub'; | ||
|
||
// Example of strongly typed globals in a subcommand which is added to program using .addCommand(). | ||
|
||
export function AssembleProgram() { | ||
const program = createProgram(); | ||
const subCommand = createSub(); | ||
program.addCommand(subCommand); | ||
return program; | ||
} |
Oops, something went wrong.