From 37588a9f3d3aa06d0a175afdee41a77b353020d0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 30 Dec 2015 18:48:28 +0100 Subject: [PATCH 1/5] Remove hello-world output --- src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index c695da28..4ead5cb6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,6 +49,4 @@ fn main() { } else { info!("No commandline call...") } - - info!("Hello, world!"); } From 708f2bcff19d82d32292e23572c0fbfd623459bd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 30 Dec 2015 18:50:09 +0100 Subject: [PATCH 2/5] Added indent for readability --- src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4ead5cb6..3f5bca4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,14 +28,13 @@ pub mod util; pub use module::bm::BM; fn main() { - let yaml = load_yaml!("../etc/cli.yml"); - let app = App::from_yaml(yaml); - let config = CliConfig::new(app); + let yaml = load_yaml!("../etc/cli.yml"); + let app = App::from_yaml(yaml); + let config = CliConfig::new(app); let configuration = Configuration::new(&config); + let logger = ImagLogger::init(&configuration, &config); - let logger = ImagLogger::init(&configuration, &config); debug!("Logger created!"); - debug!("CliConfig : {:?}", &config); debug!("Configuration: {:?}", &configuration); From a2856d86719df24fc572054713e76e8aade7e43f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 30 Dec 2015 22:46:40 +0100 Subject: [PATCH 3/5] Remove unused imports --- src/main.rs | 2 -- src/module/bm/mod.rs | 11 +---------- src/module/helpers/cli.rs | 2 -- src/module/helpers/utils.rs | 1 - src/module/mod.rs | 8 +------- src/storage/file/hash.rs | 3 +-- src/storage/file/header/spec.rs | 2 +- src/storage/file/id.rs | 3 --- src/storage/file/id_type.rs | 2 -- src/storage/file/mod.rs | 8 -------- src/storage/mod.rs | 7 +++---- src/ui/external/editor.rs | 10 ---------- 12 files changed, 7 insertions(+), 52 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3f5bca4f..6ae80f6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,8 +9,6 @@ extern crate url; extern crate config; -use std::process::exit; - pub use cli::CliConfig; pub use configuration::Configuration; pub use runtime::{ImagLogger, Runtime}; diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index a2b880ae..9a043089 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -1,20 +1,13 @@ -use std::fmt::{Debug, Display, Formatter}; -use std::rc::Rc; -use std::cell::RefCell; +use std::fmt::{Debug, Formatter}; use std::fmt; use std::ops::Deref; use std::process::exit; use clap::ArgMatches; -use regex::Regex; use runtime::Runtime; use module::Module; -use storage::Store; -use storage::file::hash::FileHash; -use storage::file::id::FileID; -use storage::file::File; use storage::parser::FileHeaderParser; use storage::parser::Parser; use storage::json::parser::JsonHeaderParser; @@ -142,8 +135,6 @@ impl<'a> BM<'a> { * Subcommand: remove */ fn command_remove(&self, matches: &ArgMatches) -> bool { - use std::process::exit; - let parser = Parser::new(JsonHeaderParser::new(None)); let filter : Box = get_file_filter_by_cli(&parser, matches, "id", "match", "tags", None); let result = self.rt diff --git a/src/module/helpers/cli.rs b/src/module/helpers/cli.rs index 7d96cef1..c9cbbce8 100644 --- a/src/module/helpers/cli.rs +++ b/src/module/helpers/cli.rs @@ -8,8 +8,6 @@ use regex::Regex; use storage::file::File; use storage::file::hash::FileHash; -use storage::file::header::data::FileHeaderData; -use storage::file::id::FileID; use storage::json::parser::JsonHeaderParser; use storage::parser::FileHeaderParser; use storage::parser::Parser; diff --git a/src/module/helpers/utils.rs b/src/module/helpers/utils.rs index a890c5fd..10566f44 100644 --- a/src/module/helpers/utils.rs +++ b/src/module/helpers/utils.rs @@ -3,7 +3,6 @@ */ pub mod cli { use clap::ArgMatches; - use regex::Regex; use runtime::Runtime; diff --git a/src/module/mod.rs b/src/module/mod.rs index 95f0b7be..24fdc9a5 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -1,13 +1,7 @@ -use std::collections::HashMap; -use std::error::Error; -use std::fmt::{Debug, Display, Formatter}; -use std::fmt::Result as FMTResult; -use std::result::Result; +use std::fmt::Debug; use clap::ArgMatches; -use runtime::Runtime; - pub mod bm; pub mod helpers; diff --git a/src/storage/file/hash.rs b/src/storage/file/hash.rs index 4b364b25..9b55ed60 100644 --- a/src/storage/file/hash.rs +++ b/src/storage/file/hash.rs @@ -1,6 +1,5 @@ use std::convert::{From, Into}; -use std::error::Error; -use std::fmt::{Debug, Display, Formatter}; +use std::fmt::{Display, Formatter}; use std::fmt; use std::hash::Hash; use uuid::Uuid; diff --git a/src/storage/file/header/spec.rs b/src/storage/file/header/spec.rs index bcec162e..885e0beb 100644 --- a/src/storage/file/header/spec.rs +++ b/src/storage/file/header/spec.rs @@ -1,4 +1,4 @@ -use std::fmt::{Debug, Display, Formatter}; +use std::fmt::{Display, Formatter}; use std::fmt; #[derive(Debug)] diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index 29a6c752..afdc3d3d 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -1,9 +1,6 @@ use std::convert::{From, Into}; -use std::error::Error; use std::fmt::{Debug, Display, Formatter}; use std::fmt; -use std::hash::Hash; -use std::path::PathBuf; use std::result::Result; use std::str::FromStr; diff --git a/src/storage/file/id_type.rs b/src/storage/file/id_type.rs index b9532262..dbb498b6 100644 --- a/src/storage/file/id_type.rs +++ b/src/storage/file/id_type.rs @@ -1,7 +1,5 @@ use std::convert::{From, Into}; -use std::error::Error; use std::str::FromStr; -use std::hash::Hash; #[derive(Debug)] #[derive(Clone)] diff --git a/src/storage/file/mod.rs b/src/storage/file/mod.rs index 733fa376..11b1e827 100644 --- a/src/storage/file/mod.rs +++ b/src/storage/file/mod.rs @@ -1,4 +1,3 @@ -use std::error::Error; use std::fmt::{Debug, Display, Formatter}; use std::fmt; @@ -9,14 +8,7 @@ pub mod id_type; pub mod header; pub mod hash; - -use module::Module; use storage::file::id::*; -use storage::file::id_type::FileIDType; -use storage::file::hash::FileHash; -use super::parser::{FileHeaderParser, Parser, ParserError}; - -use self::header::spec::*; use self::header::data::*; /** diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 8f2a3707..fdd9b43a 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -12,12 +12,11 @@ pub mod parser; pub mod json; use module::Module; -use runtime::Runtime; use storage::file::File; use storage::file::id::FileID; use storage::file::id_type::FileIDType; use storage::file::hash::FileHash; -use storage::parser::{FileHeaderParser, Parser, ParserError}; +use storage::parser::{FileHeaderParser, Parser}; use storage::file::header::data::FileHeaderData; type Cache = HashMap>>; @@ -261,7 +260,7 @@ impl Store { }) } - use glob::{glob, Paths, PatternError}; + use glob::glob; let hashstr : String = hash.into(); let globstr = format!("{}/*-{}.imag", self.storepath, hashstr); @@ -323,7 +322,7 @@ impl Store { -> Vec>> where HP: FileHeaderParser { - use glob::{glob, Paths, PatternError}; + use glob::glob; let globstr = format!("{}/{}-*.imag", self.storepath, m.name()); let mut res = vec![]; diff --git a/src/ui/external/editor.rs b/src/ui/external/editor.rs index 3daa1d40..d6030a5e 100644 --- a/src/ui/external/editor.rs +++ b/src/ui/external/editor.rs @@ -1,12 +1,3 @@ -use std::ops::Drop; - -use std::path::PathBuf; -use std::fs::File; -use std::error::Error; - -use std::fmt::{Debug, Display, Formatter}; -use std::fmt; - use runtime::Runtime; /** @@ -17,7 +8,6 @@ pub fn let_user_provide_content(rt: &Runtime) -> Option { use std::io::Read; use std::fs::File; use std::process::Command; - use std::process::Child; let filepath = "/tmp/imag-tmp.md"; let file_created = File::create(filepath) From 37f3c909146c7c96e0c3a5265cdf948d0f3b5ddf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 30 Dec 2015 22:47:28 +0100 Subject: [PATCH 4/5] Remove dead code --- src/main.rs | 2 +- src/module/bm/mod.rs | 4 ---- src/ui/file.rs | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6ae80f6a..3d225826 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,7 @@ fn main() { let app = App::from_yaml(yaml); let config = CliConfig::new(app); let configuration = Configuration::new(&config); - let logger = ImagLogger::init(&configuration, &config); + ImagLogger::init(&configuration, &config); debug!("Logger created!"); debug!("CliConfig : {:?}", &config); diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 9a043089..0ed5d392 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -31,10 +31,6 @@ impl<'a> BM<'a> { } } - fn runtime(&self) -> &Runtime { - &self.rt - } - /** * Subcommand: add */ diff --git a/src/ui/file.rs b/src/ui/file.rs index 369c7164..3feb8eab 100644 --- a/src/ui/file.rs +++ b/src/ui/file.rs @@ -120,8 +120,6 @@ impl FilePrinter for SimplePrinter { * Table printer to print file information in a nice ASCII-table */ pub struct TablePrinter { - verbose: bool, - debug: bool, sp: SimplePrinter, } @@ -129,8 +127,6 @@ impl FilePrinter for TablePrinter { fn new(verbose: bool, debug: bool) -> TablePrinter { TablePrinter { - debug: debug, - verbose: verbose, sp: SimplePrinter::new(verbose, debug), } } From d6bd011d95238fde0979562f121fb60b3b81c182 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 30 Dec 2015 23:00:30 +0100 Subject: [PATCH 5/5] Add try!() around write!() --- src/module/bm/mod.rs | 2 +- src/storage/file/header/mod.rs | 4 ++-- src/storage/file/id.rs | 8 ++++---- src/storage/file/mod.rs | 8 ++++---- src/storage/json/parser.rs | 4 ++-- src/storage/parser.rs | 13 ++++++------- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 0ed5d392..f2b60468 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -294,7 +294,7 @@ impl<'a> Module<'a> for BM<'a> { impl<'a> Debug for BM<'a> { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "BM"); + try!(write!(fmt, "BM")); Ok(()) } diff --git a/src/storage/file/header/mod.rs b/src/storage/file/header/mod.rs index 8725d40d..cf0e8535 100644 --- a/src/storage/file/header/mod.rs +++ b/src/storage/file/header/mod.rs @@ -47,7 +47,7 @@ impl<'a> Error for MatchError<'a> { impl<'a> Debug for MatchError<'a> { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "{}", self.format()); + try!(write!(fmt, "{}", self.format())); Ok(()) } @@ -56,7 +56,7 @@ impl<'a> Debug for MatchError<'a> { impl<'a> Display for MatchError<'a> { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "{}", self.format()); + try!(write!(fmt, "{}", self.format())); Ok(()) } diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index afdc3d3d..6d239381 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -97,9 +97,9 @@ impl FileID { impl Debug for FileID { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "FileID[{:?}]: {:?}", + try!(write!(fmt, "FileID[{:?}]: {:?}", self.id_type, - self.id); + self.id)); Ok(()) } @@ -108,9 +108,9 @@ impl Debug for FileID { impl Display for FileID { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "FileID[{:?}]: {:?}", + try!(write!(fmt, "FileID[{:?}]: {:?}", self.id_type, - self.id); + self.id)); Ok(()) } diff --git a/src/storage/file/mod.rs b/src/storage/file/mod.rs index 11b1e827..4dde562a 100644 --- a/src/storage/file/mod.rs +++ b/src/storage/file/mod.rs @@ -85,7 +85,7 @@ impl File { impl Display for File { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, + try!(write!(fmt, "[File] Owner : '{:?}' FileID: '{:?}' Header: '{:?}' @@ -93,7 +93,7 @@ impl Display for File { self.owning_module_name, self.header, self.data, - self.id); + self.id)); Ok(()) } @@ -102,7 +102,7 @@ impl Display for File { impl Debug for File { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, + try!(write!(fmt, "[File] Owner : '{:?}' FileID: '{:?}' Header: '{:?}' @@ -110,7 +110,7 @@ impl Debug for File { self.owning_module_name, self.id, self.header, - self.data); + self.data)); Ok(()) } diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index ea5738b7..c49855f4 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -30,7 +30,7 @@ impl JsonHeaderParser { impl Display for JsonHeaderParser { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "JsonHeaderParser"); + try!(write!(fmt, "JsonHeaderParser")); Ok(()) } @@ -39,7 +39,7 @@ impl Display for JsonHeaderParser { impl Debug for JsonHeaderParser { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "JsonHeaderParser, Spec: {:?}", self.spec); + try!(write!(fmt, "JsonHeaderParser, Spec: {:?}", self.spec)); Ok(()) } diff --git a/src/storage/parser.rs b/src/storage/parser.rs index bcbf9a53..70cd3acb 100644 --- a/src/storage/parser.rs +++ b/src/storage/parser.rs @@ -57,13 +57,13 @@ impl Error for ParserError { impl Debug for ParserError { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "ParserError: {}\n\n", self.summary); + try!(write!(fmt, "ParserError: {}\n\n", self.summary)); if let Some(ref e) = self.explanation { - write!(fmt, "{}\n\n", e); + try!(write!(fmt, "{}\n\n", e)); } - write!(fmt, "On position {}\nin\n{}", self.index, self.parsertext); + try!(write!(fmt, "On position {}\nin\n{}", self.index, self.parsertext)); Ok(()) } @@ -72,10 +72,10 @@ impl Debug for ParserError { impl Display for ParserError { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "ParserError: {}", self.summary); + try!(write!(fmt, "ParserError: {}", self.summary)); if let Some(ref e) = self.explanation { - write!(fmt, "\n\n{}", e); + try!(write!(fmt, "\n\n{}", e)); } Ok(()) @@ -196,8 +196,7 @@ impl Debug for Parser { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "Parser<{:?}>", self.headerp); - + try!(write!(fmt, "Parser<{:?}>", self.headerp)); Ok(()) }