mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
feat: better error message for non-existent env value
This commit is contained in:
parent
a201c18c01
commit
dc7f7e9c8d
2 changed files with 17 additions and 5 deletions
|
|
@ -41,7 +41,14 @@ pub fn command_output(shell: &str, command: &str) -> String {
|
|||
}
|
||||
|
||||
fn last_command(shell: &str) -> String {
|
||||
let last_command = std::env::var("_PR_LAST_COMMAND").expect("No _PR_LAST_COMMAND in environment. Did you aliased the command with the correct argument?");
|
||||
let last_command = match std::env::var("_PR_LAST_COMMAND") {
|
||||
Ok(command) => command,
|
||||
Err(_) => {
|
||||
eprintln!("No _PR_LAST_COMMAND in environment. Did you aliased the command with the correct argument?\n\nUse `pay-respects -h` for help");
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
match shell {
|
||||
"bash" => {
|
||||
let first_line = last_command.lines().next().unwrap().trim();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue