Skip to content

Commit

Permalink
fix(cheat): abort when no cheat sheet found for the command
Browse files Browse the repository at this point in the history
  • Loading branch information
figsoda committed Mar 16, 2023
1 parent 0ab80fe commit 9156919
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/error.rs
Expand Up @@ -15,6 +15,9 @@ pub enum Error {
/// Error that might occur when running on unsupported platforms.
#[error("Unsupported platform.")]
UnsupportedPlatformError,
/// Error that might occur when trying to show the cheat sheet
#[error("No cheat sheet found for `{0}`")]
CheatSheetNotFoundError(String),
}

/// Type alias for the standard [`Result`] type.
Expand Down
3 changes: 3 additions & 0 deletions src/helper/docs/cheat.rs
Expand Up @@ -25,6 +25,9 @@ pub fn show_cheat_sheet<Output: Write>(
.call()
.map_err(|e| Error::from(Box::new(e)))?
.into_string()?;
if cheat_sheet.starts_with("Unknown topic.") {
return Err(Error::CheatSheetNotFoundError(cmd.into()));
}
if let Some(pager) = pager {
let mut process = if cfg!(target_os = "windows") {
Command::new("cmd")
Expand Down

0 comments on commit 9156919

Please sign in to comment.