diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-05-07 20:04:13 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2021-05-07 20:04:13 -0400 |
commit | e67ea4c5f8e6d4790c43159e965417b59603e5a5 (patch) | |
tree | 293a9b8929ef103776953e2e188ad1681b48b91c /src/main.rs | |
parent | c8709ff70570e9e8aa5f44c5e30c1027d9a0c701 (diff) |
add more automatic error handling
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 282d291..cdb6214 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ use crate::config::{ AppConfig, AppKeyMapping, AppMimetypeRegistry, AppTheme, ConfigStructure, JoshutoPreview, }; use crate::context::AppContext; -use crate::error::{JoshutoError, JoshutoErrorKind}; +use crate::error::JoshutoError; use crate::run::run; const PROGRAM_NAME: &str = "joshuto"; @@ -67,12 +67,8 @@ pub struct Args { fn run_joshuto(args: Args) -> Result<(), JoshutoError> { if args.version { let version = env!("CARGO_PKG_VERSION"); - println!("{}", version); - let err = JoshutoError::new( - JoshutoErrorKind::EnvVarNotPresent, - "CARGO_PKG_VERSION variable not found".to_string(), - ); - return Err(err); + println!("{}-{}", PROGRAM_NAME, version); + return Ok(()); } if let Some(p) = args.path.as_ref() { match std::env::set_current_dir(p.as_path()) { @@ -106,7 +102,6 @@ fn run_joshuto(args: Args) -> Result<(), JoshutoError> { )?; file.write_all("\n".as_bytes())?; } - Ok(()) } |