Skip to content

Commit

Permalink
update messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
meop committed Oct 22, 2024
1 parent 9c80d30 commit d7f232c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ pub(crate) fn run_cmd(command: &String) -> Result<(), Error> {

pub(crate) fn run_cmd_filtered(command: &String, filters: &Vec<String>) -> Result<(), Error> {
if filters.is_empty() {
run_cmd(command)
} else {
let (shell, cmd_arg) = get_shell_cmd_arg();
logcln(command, Category::Arg);
let output = Command::new(shell).arg(cmd_arg).arg(command).output()?;
return run_cmd(command);
}

let (shell, cmd_arg) = get_shell_cmd_arg();
logcln(command, Category::Arg);
let output = Command::new(shell).arg(cmd_arg).arg(command).output()?;

logcln("filter matches:", Category::Info);
for line in String::from_utf8(output.stdout).unwrap().lines() {
for filter in filters {
if line.contains(filter) {
logln(line);
}
logcln("matches:", Category::Info);
for line in String::from_utf8(output.stdout).unwrap().lines() {
for filter in filters {
if line.contains(filter) {
logln(line);
}
}
Ok(())
}
Ok(())
}
16 changes: 8 additions & 8 deletions src/me.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,29 @@ fn upgrade() -> Result<(), Box<dyn Error>> {
.fetch()?;

if releases.len() == 0 {
logcln("no releases found", Category::Info);
logcln("releases empty", Category::Info);
return Ok(());
}

let running_version = self_update::cargo_crate_version!();
let current_version = self_update::cargo_crate_version!();
let latest_version = &releases[0].version;

logcln(
&format!("running version: {running_version}"),
&format!("current: {current_version}"),
Category::Info,
);
logcln(&format!("latest version: {latest_version}"), Category::Info);
logcln(&format!("latest: {latest_version}"), Category::Info);

if version_compare::compare_to(running_version, latest_version, Cmp::Ge).unwrap() {
if version_compare::compare_to(current_version, latest_version, Cmp::Ge).unwrap() {
logcln(
"already at or above latest version",
"already at latest",
Category::Info,
);
return Ok(());
}

if !Confirm::new()
.with_prompt("upgrade to latest version?")
.with_prompt("upgrade to latest?")
.default(true)
.interact()?
{
Expand Down Expand Up @@ -134,7 +134,7 @@ fn upgrade() -> Result<(), Box<dyn Error>> {
.to_dest(Path::new(&cur_path_str))?;
} else {
logcln(
&format!("latest version does not contain target: {binary}"),
&format!("release missing: {binary}"),
Category::Info,
);
return Ok(());
Expand Down

0 comments on commit d7f232c

Please sign in to comment.