diff --git a/src/main.rs b/src/main.rs index c695da28..3d225826 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}; @@ -28,14 +26,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); + ImagLogger::init(&configuration, &config); - let logger = ImagLogger::init(&configuration, &config); debug!("Logger created!"); - debug!("CliConfig : {:?}", &config); debug!("Configuration: {:?}", &configuration); @@ -49,6 +46,4 @@ fn main() { } else { info!("No commandline call...") } - - info!("Hello, world!"); } diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 369ee59b..8ce411ff 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; @@ -38,10 +31,6 @@ impl<'a> BM<'a> { } } - fn runtime(&self) -> &Runtime { - &self.rt - } - /** * Subcommand: add */ @@ -142,8 +131,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 @@ -307,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/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/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/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..6d239381 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; @@ -100,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(()) } @@ -111,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/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..4dde562a 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::*; /** @@ -93,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: '{:?}' @@ -101,7 +93,7 @@ impl Display for File { self.owning_module_name, self.header, self.data, - self.id); + self.id)); Ok(()) } @@ -110,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: '{:?}' @@ -118,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/mod.rs b/src/storage/mod.rs index 3e33c681..e47a7a73 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>>; @@ -266,7 +265,7 @@ impl Store { }) } - use glob::{glob, Paths, PatternError}; + use glob::glob; let hashstr : String = hash.into(); let globstr = format!("{}/*-{}.imag", self.storepath, hashstr); @@ -301,7 +300,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/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(()) } 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) 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), } }