Skip to content

Commit 9d4b0e6

Browse files
committed
noop func
1 parent 5e52540 commit 9d4b0e6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

examples/demo.t.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import t from '../src/t';
1+
import t, { noopHandler } from '../src/t';
22

33
// Global options
44
t.option(
@@ -62,7 +62,7 @@ devCmd.option(
6262
'p'
6363
);
6464

65-
devCmd.option('verbose', 'Enable verbose logging', undefined, 'v', true);
65+
devCmd.option('verbose', 'Enable verbose logging', noopHandler, 'v', true);
6666

6767
// Serve command
6868
const serveCmd = t.command('serve', 'Start the server');

src/t.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export type OptionHandler = (
2020
options: OptionsMap
2121
) => void;
2222

23+
export const noopHandler: OptionHandler = function () {};
24+
2325
// Completion result types
2426
export type Completion = {
2527
description?: string;
@@ -63,7 +65,7 @@ export class Option {
6365
command: Command,
6466
value: string,
6567
description: string,
66-
handler?: OptionHandler,
68+
handler: OptionHandler = noopHandler,
6769
alias?: string,
6870
isBoolean?: boolean
6971
) {
@@ -91,7 +93,7 @@ export class Command {
9193
option(
9294
value: string,
9395
description: string,
94-
handler?: OptionHandler,
96+
handler: OptionHandler = noopHandler,
9597
alias?: string,
9698
isBoolean?: boolean
9799
) {

0 commit comments

Comments
 (0)