Skip to content

Commit

Permalink
Move std::process::exit out of anything nested
Browse files Browse the repository at this point in the history
  • Loading branch information
kimono-koans committed Nov 30, 2023
1 parent 0e879a3 commit 7d03ac7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
17 changes: 10 additions & 7 deletions src/config/install_hot_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ pub fn install_hot_keys() -> HttmResult<()> {
) {
Ok(_) => {
eprintln!("httm: zsh hot keys were installed successfully.");
std::process::exit(0)
}
Err(err) => {
Err(HttmError::with_context("httm: could not move .httm-key-bindings.zsh.tmp to .httm-key-bindings.zsh for the following reason: ", &err).into())
return Err(HttmError::with_context("httm: could not move .httm-key-bindings.zsh.tmp to .httm-key-bindings.zsh for the following reason: ", &err).into())
}
}
}
Err(err) => Err(HttmError::with_context(
"Opening ~/.httm-key-bindings.zsh.tmp file failed for the following reason: ",
&err,
)
.into()),
Err(err) => {
return Err(HttmError::with_context(
"Opening ~/.httm-key-bindings.zsh.tmp file failed for the following reason: ",
&err,
)
.into())
}
}

std::process::exit(0)
}
8 changes: 5 additions & 3 deletions src/exec/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ impl InteractiveSelect {
// one only allow one to select one path string during select
// but we retain paths_selected_in_browse because we may need
// it later during restore if opt_overwrite is selected
InteractiveMode::Restore(_) => InteractiveRestore::exec(select_result),
InteractiveMode::Select(select_mode) => select_result.print_selections(select_mode),
InteractiveMode::Restore(_) => InteractiveRestore::exec(select_result)?,
InteractiveMode::Select(select_mode) => select_result.print_selections(select_mode)?,
InteractiveMode::Browse => unreachable!(),
}

std::process::exit(0);
}

fn new(browse_result: InteractiveBrowse) -> HttmResult<Self> {
Expand Down Expand Up @@ -219,7 +221,7 @@ impl InteractiveSelect {
.map(Path::new)
.try_for_each(|snap_path| self.print_snap_path(snap_path, select_mode))?;

std::process::exit(0);
Ok(())
}

fn print_snap_path(&self, snap_path: &Path, select_mode: &SelectMode) -> HttmResult<()> {
Expand Down
6 changes: 4 additions & 2 deletions src/exec/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ impl PruneSnaps {
false
};

Self::interactive_prune(&snap_name_map, select_mode)
Self::interactive_prune(&snap_name_map, select_mode)?;

std::process::exit(0)
}

fn interactive_prune(snap_name_map: &SnapNameMap, select_mode: bool) -> HttmResult<()> {
Expand Down Expand Up @@ -97,7 +99,7 @@ impl PruneSnaps {
}
}

std::process::exit(0)
Ok(())
}

fn prune_snaps(snap_name_map: &SnapNameMap) -> HttmResult<()> {
Expand Down

0 comments on commit 7d03ac7

Please sign in to comment.