pub struct OutputFlags { /* private fields */ }Expand description
CLI flag configuration for output behavior
OutputFlags captures the --quiet, --verbose, and --json flags that the main!() macro
adds to every Clawless application. After parsing, the flags are forwarded to the
TerminalPresenter to control how events are rendered.
OutputFlags does not produce output itself. Commands use the core Output type to emit
events; OutputFlags configures the presenter that renders them.
§Examples
use clawless_cli::output::OutputFlags;
let flags = OutputFlags::new(
clawless_cli::output::Verbosity::Default,
clawless_cli::output::OutputMode::Text,
);
assert_eq!(flags.verbosity(), clawless_cli::output::Verbosity::Default);
assert_eq!(flags.mode(), clawless_cli::output::OutputMode::Text);Implementations§
Source§impl OutputFlags
impl OutputFlags
Sourcepub fn new(verbosity: Verbosity, mode: OutputMode) -> Self
pub fn new(verbosity: Verbosity, mode: OutputMode) -> Self
Creates a new OutputFlags with the given verbosity and mode
§Examples
use clawless_cli::output::{OutputFlags, OutputMode, Verbosity};
let flags = OutputFlags::new(Verbosity::Default, OutputMode::Text);
assert_eq!(flags.verbosity(), Verbosity::Default);
assert_eq!(flags.mode(), OutputMode::Text);Sourcepub fn verbosity(&self) -> Verbosity
pub fn verbosity(&self) -> Verbosity
Returns the verbosity level
§Examples
use clawless_cli::output::{OutputFlags, OutputMode, Verbosity};
let flags = OutputFlags::new(Verbosity::Verbose, OutputMode::Text);
assert_eq!(flags.verbosity(), Verbosity::Verbose);Sourcepub fn mode(&self) -> OutputMode
pub fn mode(&self) -> OutputMode
Returns the output mode
§Examples
use clawless_cli::output::{OutputFlags, OutputMode, Verbosity};
let flags = OutputFlags::new(Verbosity::Default, OutputMode::Json);
assert_eq!(flags.mode(), OutputMode::Json);Sourcepub fn augment_command(command: Command) -> Command
pub fn augment_command(command: Command) -> Command
Attaches --quiet, --verbose, and --json as global flags to a clap::Command
The --quiet and --verbose flags conflict with each other. All three flags are global,
meaning they can appear before or after the subcommand name.
This method is called by the main!() macro expansion. Command authors do not call it
directly.
§Examples
let command = clap::Command::new("test");
let command = clawless_cli::output::OutputFlags::augment_command(command);Sourcepub fn from_arg_matches(matches: &ArgMatches) -> Self
pub fn from_arg_matches(matches: &ArgMatches) -> Self
Constructs an OutputFlags from parsed CLI flags
Reads the --quiet, --verbose, and --json flags from the given ArgMatches and
returns an OutputFlags configured accordingly. The command must have been augmented with
augment_command before parsing.
This method is called by the main!() macro expansion. Command authors do not call it
directly.
§Examples
let command = clawless_cli::output::OutputFlags::augment_command(
clap::Command::new("test"),
);
let matches = command.get_matches_from(vec!["test", "--quiet"]);
let flags = clawless_cli::output::OutputFlags::from_arg_matches(&matches);
assert_eq!(flags.verbosity(), clawless_cli::output::Verbosity::Quiet);Trait Implementations§
Source§impl Clone for OutputFlags
impl Clone for OutputFlags
Source§fn clone(&self) -> OutputFlags
fn clone(&self) -> OutputFlags
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more