Skip to content

Commit

Permalink
removed unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
gwirn committed Apr 29, 2023
1 parent 379d4ae commit f1811ff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
10 changes: 2 additions & 8 deletions src/argparse.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use crate::date_utils::{
append_file, argsort, check_dates, offset_and_time, read_file, remove_entry, saved_data_header,
time_date_lef, SavedDate,
};
use crate::date_utils::{append_file, check_dates, remove_entry, SavedDate};
use crate::view_dates::{get_next_n, grep_by_date, grep_by_description, last_added};
use crate::view_month::{appointment_check, month_len, month_view};
use crate::DATE_FILE_PATH;
use chrono::Datelike;
use chrono::{Local, NaiveDate};
use chrono::NaiveDate;
use regex::Regex;
use std::fs;
use std::io;
use std::io::prelude::*;

pub fn arg_print(arg_short: &str, arg_long: &str, dtype: &str, msg: &str) {
println!("{} | {} <{}>\n {}\n", arg_short, arg_long, dtype, msg)
Expand Down
7 changes: 3 additions & 4 deletions src/date_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use crate::encrypt::{gen_key_pwd, get_pwd_file, read_bin, write_bin};
use crate::{PWD_LOC, SALT_LOC};
use chrono::{DateTime, Local, NaiveDateTime, Utc};
use notify_rust::Notification;
use orion::{aead, kdf};
use orion::aead;
use std::fmt;
use std::fs;
use std::io::prelude::*;
use std::path::Path;

#[derive(Debug)]
Expand Down Expand Up @@ -155,9 +153,10 @@ pub fn read_file(filepath: &str) -> Vec<SavedDate> {
}

pub fn remove_entry(rm_id: &str, file_path: &str) {
// remove entry by id
let file_content = read_file(file_path);
let mut removed = Vec::new();
for (ci, i) in file_content.iter().enumerate() {
for i in file_content.iter() {
if i.id.to_string() != rm_id {
let acc_line = format!(
"{},{},{},{},{}-X-",
Expand Down
6 changes: 5 additions & 1 deletion src/encrypt.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use orion::{aead, kdf};
use orion::kdf;
use std::fs;
use std::fs::File;
use std::io::prelude::*;

pub fn get_pwd_file(file_path: &str) -> String {
// get password from file
let pwd: String = fs::read_to_string(file_path)
.expect("Couldn't read pwd file")
.trim()
Expand All @@ -12,6 +13,7 @@ pub fn get_pwd_file(file_path: &str) -> String {
}

pub fn gen_key_pwd(
// generate salt and password from password string
my_pwd: &str,
salt: orion::kdf::Salt,
) -> (orion::kdf::Salt, orion::aead::SecretKey) {
Expand All @@ -23,6 +25,7 @@ pub fn gen_key_pwd(
}

pub fn write_bin(text: &Vec<u8>, file_path: &str) {
// write encrypted text to file
let mut old_path: String = file_path.to_owned();
old_path.push_str("_old");
match fs::copy(&file_path, &old_path) {
Expand All @@ -38,6 +41,7 @@ pub fn write_bin(text: &Vec<u8>, file_path: &str) {
.expect("Couldn't write content to binary file");
}
pub fn read_bin(file_path: &str) -> Vec<u8> {
// read binary file
let mut file = File::open(file_path).expect("Couldn't open binary file");
let mut buffer = Vec::<u8>::new();
file.read_to_end(&mut buffer)
Expand Down
1 change: 0 additions & 1 deletion src/view_month.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::date_utils::SavedDate;
use chrono::NaiveDate;
use std::collections::HashMap;

pub fn month_len(year: &i32, month: &u32) -> u32 {
// get number of days of the month
Expand Down

0 comments on commit f1811ff

Please sign in to comment.