Skip to content

Commit

Permalink
fix: do not set debug mode when calling mise -v
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 9, 2024
1 parent d6c2cd9 commit 371f95b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub enum LevelFilter {
}

#[derive(clap::Parser, Debug)]
#[clap(name = "mise", version = &*version::VERSION, about, long_about = LONG_ABOUT, after_long_help = AFTER_LONG_HELP, author = "Jeff Dickey <@jdx>", arg_required_else_help = true)]
#[clap(name = "mise", about, long_about = LONG_ABOUT, after_long_help = AFTER_LONG_HELP, author = "Jeff Dickey <@jdx>", arg_required_else_help = true)]
pub struct Cli {
#[clap(subcommand)]
pub command: Option<Commands>,
Expand Down Expand Up @@ -142,6 +142,8 @@ pub struct Cli {
/// Show extra output (use -vv for even more)
#[clap(short='v', long, global=true, overrides_with="quiet", action=ArgAction::Count)]
pub verbose: u8,
#[clap(long, short='V', hide=true)]
pub version: bool,
/// Answer yes to all confirmation prompts
#[clap(short = 'y', long, global = true)]
pub yes: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn print_version_if_requested(args: &[String]) -> std::io::Result<bool> {
let mise_bin = "mise.exe";
if args.len() == 2 && *env::MISE_BIN_NAME == mise_bin {
let cmd = &args[1].to_lowercase();
if cmd == "version" || cmd == "-v" || cmd == "--version" {
if cmd == "version" || cmd == "-v" || cmd == "--version" || cmd == "v" {
show_version()?;
return Ok(true);
}
Expand Down
5 changes: 4 additions & 1 deletion src/config/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use confique::env::parse::{list_by_colon, list_by_comma};
use confique::{Config, Partial};
use eyre::{bail, Result};
use indexmap::{indexmap, IndexMap};
use itertools::Itertools;
use once_cell::sync::Lazy;
use serde::ser::Error;
use serde_derive::{Deserialize, Serialize};
Expand Down Expand Up @@ -142,7 +143,9 @@ impl Settings {
settings.trace = true;
}
}
if settings.verbose {
let args = env::args().collect_vec();
// handle the special case of `mise -v` which should show version, not set verbose
if settings.verbose && !(args.len() == 2 && args[1] == "-v") {
settings.quiet = false;
if settings.log_level != "trace" {
settings.log_level = "debug".to_string();
Expand Down

0 comments on commit 371f95b

Please sign in to comment.