Skip to content

Commit

Permalink
fix: do not set debug mode when calling mise -v (#3418)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Dec 9, 2024
1 parent 979fe07 commit 47cce06
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
9 changes: 2 additions & 7 deletions man/man1/mise.1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.TH mise 1 "mise 2024.12.3"
.TH mise 1 "mise "
.SH NAME
mise \- The front\-end to your dev env
.SH SYNOPSIS
\fBmise\fR [\fB\-C\fR|\fB\-\-cd\fR] [\fB\-E\fR|\fB\-\-env\fR] [\fB\-j\fR|\fB\-\-jobs\fR] [\fB\-q\fR|\fB\-\-quiet\fR] [\fB\-\-raw\fR] [\fB\-v\fR|\fB\-\-verbose\fR]... [\fB\-y\fR|\fB\-\-yes\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fITASK\fR] [\fITASK_ARGS\fR] [\fIsubcommands\fR]
\fBmise\fR [\fB\-C\fR|\fB\-\-cd\fR] [\fB\-E\fR|\fB\-\-env\fR] [\fB\-j\fR|\fB\-\-jobs\fR] [\fB\-q\fR|\fB\-\-quiet\fR] [\fB\-\-raw\fR] [\fB\-v\fR|\fB\-\-verbose\fR]... [\fB\-y\fR|\fB\-\-yes\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fITASK\fR] [\fITASK_ARGS\fR] [\fIsubcommands\fR]
.SH DESCRIPTION
.PP
mise is a tool for managing runtime versions. https://github.com/jdx/mise
Expand Down Expand Up @@ -44,9 +44,6 @@ Answer yes to all confirmation prompts
\fB\-h\fR, \fB\-\-help\fR
Print help (see a summary with \*(Aq\-h\*(Aq)
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version
.TP
[\fITASK\fR]
Task to run.

Expand Down Expand Up @@ -209,7 +206,5 @@ Examples:

$ mise settings Show settings in use
$ mise settings color=0 Disable color by modifying global config file
.SH VERSION
v2024.12.3
.SH AUTHORS
Jeff Dickey <@jdx>
1 change: 1 addition & 0 deletions mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ flag "--no-timings" help="Hides elapsed time after each task completes" hide=tru
}
flag "--trace" help="Sets log level to trace" hide=true global=true
flag "-v --verbose" help="Show extra output (use -vv for even more)" var=true global=true count=true
flag "-V --version" hide=true
flag "-y --yes" help="Answer yes to all confirmation prompts" global=true
arg "[TASK]" help="Task to run" help_long="Task to run.\n\nShorthand for `mise task run <TASK>`."
arg "[TASK_ARGS]..." help="Task arguments" var=true hide=true
Expand Down
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
6 changes: 2 additions & 4 deletions src/cli/render_mangen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use std::{env, fs};
use xx::file;

use crate::cli::{version, Cli};
use crate::cli::Cli;

/// internal command to generate markdown from help
#[derive(Debug, clap::Args)]
Expand All @@ -14,9 +14,7 @@ pub struct RenderMangen {}

impl RenderMangen {
pub fn run(self) -> Result<()> {
let cli = Cli::command()
.version(version::V.to_string())
.disable_colored_help(true);
let cli = Cli::command().disable_colored_help(true);

let man = clap_mangen::Man::new(cli);
let mut buffer: Vec<u8> = Default::default();
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 47cce06

Please sign in to comment.