Skip to content

Commit

Permalink
docs: added hint about --bump flag for upgrade/outdated (#2761)
Browse files Browse the repository at this point in the history
Fixes #2759
  • Loading branch information
jdx authored Oct 14, 2024
1 parent 1b83acd commit 1c1c21c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
4 changes: 4 additions & 0 deletions docs/cli/tasks/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Tasks to run
Can specify multiple tasks by separating with `:::`
e.g.: mise run task1 arg1 arg2 ::: task2 arg1 arg2

#### Default

`default`

### `[ARGS]...`

Arguments to pass to the tasks. Use ":::" to separate tasks
Expand Down
17 changes: 17 additions & 0 deletions e2e/cli/test_outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

echo 'dummy 1' >.tool-versions
mise install [email protected]

assert_contains "mise ls --installed dummy" "1.0.0"
assert_not_contains "mise ls --installed dummy" "1.1.0"

#mise outdated dummy
#assert_contains "mise ls --installed dummy" "1.1.0"
#assert_not_contains "mise ls --installed dummy" "1.0.0"

assert "mise outdated dummy" "dummy 1 1.0.0 1.1.0 ~/workdir/.tool-versions"
assert "mise outdated dummy --bump" "dummy 1 1.0.0 2.0.0 ~/workdir/.tool-versions"

assert "mise outdated dummy --json | jq -r '.dummy.latest'" "1.1.0"
assert "mise outdated dummy --bump --json | jq -r '.dummy.latest'" "2.0.0"
28 changes: 8 additions & 20 deletions src/cli/outdated.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashSet;

use crate::cli::args::ToolArg;
use crate::config::Config;
use crate::config::CONFIG;
use crate::toolset::{OutdatedInfo, ToolsetBuilder};
use crate::ui::table;
use eyre::Result;
Expand Down Expand Up @@ -39,8 +39,7 @@ pub struct Outdated {

impl Outdated {
pub fn run(self) -> Result<()> {
let config = Config::try_get()?;
let mut ts = ToolsetBuilder::new().with_args(&self.tool).build(&config)?;
let mut ts = ToolsetBuilder::new().with_args(&self.tool).build(&CONFIG)?;
let tool_set = self
.tool
.iter()
Expand All @@ -51,12 +50,16 @@ impl Outdated {
let outdated = ts.list_outdated_versions(self.bump);
if outdated.is_empty() {
info!("All tools are up to date");
hint!(
"outdated_bump",
r#"By default, `mise outdated` only shows versions that match your config. Use `mise outdated --bump` to see all new versions."#,
""
);
} else if self.json {
self.display_json(outdated)?;
} else {
self.display(outdated)?;
}

Ok(())
}

Expand Down Expand Up @@ -96,7 +99,7 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(

#[cfg(test)]
mod tests {
use crate::test::{change_installed_version, reset};
use crate::test::reset;

#[test]
fn test_outdated() {
Expand All @@ -111,19 +114,4 @@ mod tests {
reset();
assert_cli_snapshot!("outdated", "tiny");
}

#[test]
fn test_outdated_json() {
reset();
change_installed_version("tiny", "3.1.0", "3.0.0");
assert_cli_snapshot!("outdated", "tiny", "--json");
change_installed_version("tiny", "3.0.0", "3.1.0");
}

#[test]
fn test_outdated_json_bump() {
reset();
assert_cli!("use", "tiny@2");
assert_cli_snapshot!("outdated", "tiny", "--json", "--bump");
}
}
5 changes: 5 additions & 0 deletions src/cli/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ impl Upgrade {
}
if outdated.is_empty() {
info!("All tools are up to date");
hint!(
"outdated_bump",
r#"By default, `mise upgrade` only upgrades versions that match your config. Use `mise upgrade --bump` to upgrade all new versions."#,
""
);
} else {
self.upgrade(&config, outdated)?;
}
Expand Down
13 changes: 5 additions & 8 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,11 @@ pub fn should_display_hint(id: &str) -> bool {
macro_rules! hint {
($id:expr, $message:expr, $example_cmd:expr) => {{
if $crate::output::should_display_hint($id) {
let prefix = console::style("mise ").dim().for_stderr().to_string();
let prefix = prefix
+ console::style("hint")
.dim()
.yellow()
.for_stderr()
.to_string()
.as_str();
let prefix = console::style("hint")
.dim()
.yellow()
.for_stderr()
.to_string();
let cmd = console::style($example_cmd).bold().for_stderr();
let disable_single = console::style(format!("mise settings add disable_hints {}", $id))
.bold()
Expand Down

0 comments on commit 1c1c21c

Please sign in to comment.