Skip to content

Commit

Permalink
chore(pull): merge #10
Browse files Browse the repository at this point in the history
10: fix(cheat): don't use a pager when no cheat sheet found for the command r=orhun a=figsoda

<!--- Thank you for contributing to halp! 🐙 -->

## Description

cheat.sh doesn't return 404: chubin/cheat.sh#198

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How Has This Been Tested?

```console
$ cargo run plz 42
   Compiling halp v0.1.3 (/home/figsoda/halp)
    Finished dev [unoptimized + debuginfo] target(s) in 0.37s
     Running `target/debug/halp plz 42`
❤ Select operation · Show cheat sheet
Unknown topic.
Do you mean one of these topics maybe?

    * m4 50
    * p4 50
    * r2 50
    

(ノ´ヮ`)ノ*: ・゚
 Select operation ›
  Show man page
✧ Show cheat sheet
  Exit
```

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots / Logs (if applicable)

## Types of Changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation (no code change)
- [ ] Refactor (refactoring production code)
- [ ] Other <!--- (provide information) -->

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->

- [x] My code follows the code style of this project.
- [ ] I have updated the documentation accordingly.
- [x] I have formatted the code with [rustfmt](https://github.com/rust-lang/rustfmt).
- [x] I checked the lints with [clippy](https://github.com/rust-lang/rust-clippy).
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.


Co-authored-by: figsoda <figsoda@pm.me>
  • Loading branch information
bors[bot] and figsoda committed Mar 17, 2023
2 parents 0ab80fe + 170e8a9 commit 2276a2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/helper/docs/cheat.rs
Expand Up @@ -25,7 +25,11 @@ pub fn show_cheat_sheet<Output: Write>(
.call()
.map_err(|e| Error::from(Box::new(e)))?
.into_string()?;
if let Some(pager) = pager {
// Don't use a pager when the topic is not found.
if let Some(pager) = pager
.as_ref()
.filter(|_| !cheat_sheet.starts_with("Unknown topic."))
{
let mut process = if cfg!(target_os = "windows") {
Command::new("cmd")
.args(["/C", pager])
Expand Down

0 comments on commit 2276a2c

Please sign in to comment.