aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/console.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mozart/src/console.rs')
-rw-r--r--crates/mozart/src/console.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/crates/mozart/src/console.rs b/crates/mozart/src/console.rs
index 5f108c0..e37ff23 100644
--- a/crates/mozart/src/console.rs
+++ b/crates/mozart/src/console.rs
@@ -94,17 +94,20 @@ pub struct Console {
}
impl Console {
- /// Build a `Console` from the parsed CLI.
+ /// Build a `Console` from primitive arguments.
///
- /// This is the primary constructor used in production. It reads
- /// `cli.verbose`, `cli.quiet`, `cli.ansi`, `cli.no_ansi`, and
- /// `cli.no_interaction` to configure all fields.
- pub fn from_cli(cli: &crate::commands::Cli) -> Self {
- let verbosity = Verbosity::from_flags(cli.verbose, cli.quiet);
- let decorated = Self::resolve_decorated(cli.ansi, cli.no_ansi);
+ /// This is the primary constructor. Pass the relevant CLI flag values:
+ /// - `verbose`: the `-v` flag count (0, 1, 2, 3+)
+ /// - `quiet`: whether `--quiet` was passed
+ /// - `ansi`: whether `--ansi` was passed
+ /// - `no_ansi`: whether `--no-ansi` was passed
+ /// - `no_interaction`: whether `--no-interaction` / `-n` was passed
+ pub fn new(verbose: u8, quiet: bool, ansi: bool, no_ansi: bool, no_interaction: bool) -> Self {
+ let verbosity = Verbosity::from_flags(verbose, quiet);
+ let decorated = Self::resolve_decorated(ansi, no_ansi);
colored::control::set_override(decorated);
Self {
- interactive: !cli.no_interaction,
+ interactive: !no_interaction,
verbosity,
decorated,
}