Skip to content

verbosityPlugin ​

Built directly into clerc (no extra package to install). Adds global -q, --quiet and -v, --verbose flags and wires them to ctx.log.level in a { enforce: "pre" } middleware so every downstream plugin, deprecation warning, and command handler respects the user's verbosity level.

Usage ​

ts
import { 
clerc
,
verbosityPlugin
} from "clerc";
const
cli
=
clerc
({
name
: "acme",
version
: "2.0.0",
}).
use
(
verbosityPlugin
());
cli
.
command
("sync", {
run
(
ctx
) {
ctx
.
flags
.
quiet
; // boolean
ctx
.
flags
.
verbose
; // number (-v -> 1, -vv -> 2)
ctx
.
log
.
debug
("Shown when -v / --verbose is passed");
ctx
.
log
.
info
("Suppressed when -q / --quiet is passed");
}, });

Behavior ​

FlagEffect on ctx.log.level
(none)Keeps configured default ("info").
-q, --quietSets ctx.log.level = "error" (suppresses step, info, done, debug, and warn including deprecation and update banners).
-v, --verboseCounter flag ([Boolean]); when > 0, sets ctx.log.level = "debug" (also enables stack traces in error diagnostics).

Released under the MIT License