diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..7f1b114 --- /dev/null +++ b/build.bat @@ -0,0 +1 @@ +cargo build --release \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f7dce9b..a336f14 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ use std::io::Write; mod utils; fn main() { - let version = "0.1.1"; + let version = "0.1.2"; println!("IPass v{}\n", version); let args = utils::get_args(); @@ -35,7 +35,7 @@ fn version_help(version: &str) { let mut data = version.split("."); print!("Major {} ", data.next().unwrap()); print!("Sub {} ", data.next().unwrap()); - print!("Bugfix {}", data.next().unwrap()); + println!("Bugfix {}", data.next().unwrap()); } fn help_message(args: &Vec) { @@ -96,10 +96,18 @@ fn help_message(args: &Vec) { fn list() { let paths = std::fs::read_dir(utils::get_ipass_folder()).unwrap(); + + let mut has_entry:bool = false; for path in paths { + has_entry = true; println!("Entry: \"{}\"", path.unwrap().file_name().into_string().unwrap().replace(".ipass", "")); } + + if !has_entry { + println!("No entries yet!"); + return; + } } fn add(args: &Vec) { @@ -121,7 +129,6 @@ fn add(args: &Vec) { let mut chars = String::new(); for index in chars_index { - // println!("index: {index} : {}",(index%((alphabet.len()-1) as u8))); chars += &char_set[(index%((alphabet.len()-1) as u8)) as usize].to_string(); } @@ -199,7 +206,7 @@ fn remove(args: &Vec) { let name = &args[2]; let filepath = &(utils::get_ipass_folder()+name+".ipass"); if std::path::Path::new(filepath).exists() { - if utils::prompt_answer(format!("Are you sure you want to delete {}? [y/N]", name)) == "y" { + if utils::prompt_answer(format!("Are you sure you want to delete {}? [y/N] ", name)) == "y" { std::fs::remove_file(filepath).unwrap(); println!("Removed entry \"{}\"", name); } else { @@ -235,7 +242,7 @@ fn import(args: &Vec) { file.write_all(i.as_bytes()).unwrap(); name = ""; } - print!("Imported all entries!"); + println!("Imported all entries!"); } else { println!("No such file found!"); } @@ -264,8 +271,12 @@ fn export(args: &Vec) { //TODO: compress data } } - let mut file = std::fs::File::create(location.clone()+"/export.ipassx").unwrap(); - file.write_all(collected_data.as_bytes()).unwrap(); + if let Ok(mut file) = std::fs::File::create(location.clone()+"/export.ipassx") { + file.write_all(collected_data.as_bytes()).unwrap(); - println!("Saved at: {}/export.ipassx", location); + println!("Saved at: '{}/export.ipassx'", location); + } else { + println!("Failed saving at '{}/export.ipassx' does it exist?",location) + } + } \ No newline at end of file