Skip to content

Global Flags

Clerc supports registering one or more global flags that can be used across all commands.

Example

ts
Clerc
.
create
()
.
scriptName
("my-cli")
.
description
("My CLI application")
.
version
("1.0.0")
.
globalFlag
("verbose", "Enable verbose output", {
type
:
Boolean
,
}) // Global flag .
command
("run", "Run the application")
.
on
("run", (
ctx
) => {
if (
ctx
.
flags
.
verbose
) {
console
.
log
("Verbose mode enabled");
}
console
.
log
("Running the application...");
}) .
parse
();

Released under the MIT license