Merge pull request #789 from matthiasbeyer/warning-cleanup
Warning cleanup
This commit is contained in:
commit
006db707fa
4 changed files with 51 additions and 37 deletions
|
@ -17,6 +17,21 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
|
||||
#![deny(
|
||||
non_camel_case_types,
|
||||
non_snake_case,
|
||||
path_statements,
|
||||
trivial_numeric_casts,
|
||||
unstable_features,
|
||||
unused_allocation,
|
||||
unused_import_braces,
|
||||
unused_imports,
|
||||
unused_must_use,
|
||||
unused_mut,
|
||||
unused_qualifications,
|
||||
while_true,
|
||||
)]
|
||||
|
||||
extern crate clap;
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate version;
|
||||
|
@ -30,13 +45,13 @@ extern crate libimagutil;
|
|||
|
||||
use std::process::exit;
|
||||
|
||||
use libimagentrytag::ui::{get_add_tags, get_remove_tags};
|
||||
use libimagentrylink::internal::Link;
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::setup::generate_runtime_setup;
|
||||
use libimagbookmark::collection::BookmarkCollection;
|
||||
use libimagbookmark::link::Link as BookmarkLink;
|
||||
use libimagerror::trace::{trace_error, trace_error_exit};
|
||||
use libimagerror::trace::{MapErrTrace, trace_error, trace_error_exit};
|
||||
use libimagutil::info_result::*;
|
||||
use libimagutil::iter::*;
|
||||
|
||||
mod ui;
|
||||
|
||||
|
@ -69,12 +84,14 @@ fn add(rt: &Runtime) {
|
|||
let coll = scmd.value_of("collection").unwrap(); // enforced by clap
|
||||
|
||||
BookmarkCollection::get(rt.store(), coll)
|
||||
.map(|mut collection| {
|
||||
for url in scmd.values_of("urls").unwrap() { // enforced by clap
|
||||
collection.add_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e));
|
||||
}
|
||||
});
|
||||
info!("Ready");
|
||||
.and_then(|mut collection| {
|
||||
scmd.values_of("urls")
|
||||
.unwrap() // enforced by clap
|
||||
.fold_defresult(|url| collection.add_link(BookmarkLink::from(url)))
|
||||
})
|
||||
.map_err_trace()
|
||||
.map_info_str("Ready")
|
||||
.ok();
|
||||
}
|
||||
|
||||
fn collection(rt: &Runtime) {
|
||||
|
@ -117,7 +134,8 @@ fn list(rt: &Runtime) {
|
|||
},
|
||||
Err(e) => trace_error_exit(&e, 1),
|
||||
}
|
||||
});
|
||||
})
|
||||
.ok();
|
||||
info!("Ready");
|
||||
}
|
||||
|
||||
|
@ -128,9 +146,10 @@ fn remove(rt: &Runtime) {
|
|||
BookmarkCollection::get(rt.store(), coll)
|
||||
.map(|mut collection| {
|
||||
for url in scmd.values_of("urls").unwrap() { // enforced by clap
|
||||
collection.remove_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e));
|
||||
collection.remove_link(BookmarkLink::from(url)).map_err(|e| trace_error(&e)).ok();
|
||||
}
|
||||
});
|
||||
})
|
||||
.ok();
|
||||
info!("Ready");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,21 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
|
||||
#![deny(
|
||||
non_camel_case_types,
|
||||
non_snake_case,
|
||||
path_statements,
|
||||
trivial_numeric_casts,
|
||||
unstable_features,
|
||||
unused_allocation,
|
||||
unused_import_braces,
|
||||
unused_imports,
|
||||
unused_must_use,
|
||||
unused_mut,
|
||||
unused_qualifications,
|
||||
while_true,
|
||||
)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate version;
|
||||
extern crate semver;
|
||||
|
@ -82,8 +97,6 @@ fn add(rt: &Runtime) {
|
|||
}
|
||||
|
||||
fn remove(rt: &Runtime) {
|
||||
use libimagref::error::RefErrorKind;
|
||||
use libimagerror::into::IntoError;
|
||||
use libimaginteraction::ask::ask_bool;
|
||||
|
||||
let cmd = rt.cli().subcommand_matches("remove").unwrap();
|
||||
|
@ -103,10 +116,8 @@ fn remove(rt: &Runtime) {
|
|||
|
||||
fn list(rt: &Runtime) {
|
||||
use std::process::exit;
|
||||
use std::ops::Deref;
|
||||
|
||||
use libimagentrylist::lister::Lister;
|
||||
use libimagentrylist::listers::core::CoreLister;
|
||||
use libimagref::lister::RefLister;
|
||||
|
||||
let cmd = rt.cli().subcommand_matches("list").unwrap();
|
||||
|
@ -136,6 +147,7 @@ fn list(rt: &Runtime) {
|
|||
.check_changed(do_check_changed)
|
||||
.check_changed_content(do_check_changed_content)
|
||||
.check_changed_permiss(do_check_changed_permiss)
|
||||
.list(iter.map(|e| e.into()));
|
||||
.list(iter.map(|e| e.into()))
|
||||
.ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,12 +21,9 @@ use std::default::Default;
|
|||
use std::io::stdout;
|
||||
use std::io::Write;
|
||||
|
||||
use toml::Value;
|
||||
|
||||
use libimagentrylist::lister::Lister;
|
||||
use libimagentrylist::result::Result;
|
||||
use libimagerror::trace::trace_error;
|
||||
use libimagstore::store::Entry;
|
||||
use libimagstore::store::FileLockEntry;
|
||||
use libimagerror::into::IntoError;
|
||||
use libimagentrylist::error::ListErrorKind as LEK;
|
||||
|
@ -82,20 +79,6 @@ impl Default for RefLister {
|
|||
}
|
||||
}
|
||||
|
||||
fn list_fn(e: &Entry) -> String {
|
||||
let stored_hash = match e.get_header().read("ref.content_hash") {
|
||||
Ok(Some(Value::String(s))) => s.clone(),
|
||||
_ => String::from("<Error: Could not read stored hash>"),
|
||||
};
|
||||
|
||||
let filepath = match e.get_header().read("ref.path") {
|
||||
Ok(Some(Value::String(ref s))) => s.clone(),
|
||||
_ => String::from("<Error: Could not read file path>"),
|
||||
};
|
||||
|
||||
format!("Ref({} -> {})", stored_hash, filepath)
|
||||
}
|
||||
|
||||
impl Lister for RefLister {
|
||||
|
||||
fn list<'b, I: Iterator<Item = FileLockEntry<'b>>>(&self, entries: I) -> Result<()> {
|
||||
|
@ -204,7 +187,7 @@ fn check_changed_content(r: &Ref) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_changed_permiss(r: &Ref) -> bool {
|
||||
fn check_changed_permiss(_: &Ref) -> bool {
|
||||
warn!("Permission changes tracking not supported yet.");
|
||||
false
|
||||
}
|
||||
|
|
|
@ -169,13 +169,13 @@ impl<'a> Ref<'a> {
|
|||
match can.to_str().map(String::from) {
|
||||
// UTF convert error in PathBuf::to_str(),
|
||||
None => Err(REK::PathUTF8Error.into_error()),
|
||||
Some(can) => Ok((file, opt_conhash, opt_perm, can, path_hash))
|
||||
Some(can) => Ok((opt_conhash, opt_perm, can, path_hash))
|
||||
}
|
||||
})
|
||||
|
||||
// and then we create the FileLockEntry in the Store
|
||||
// and return (filelockentry, content hash, permissions, canonicalized path)
|
||||
.and_then(|(file, opt_conhash, opt_perm, can, path_hash)| {
|
||||
.and_then(|(opt_conhash, opt_perm, can, path_hash)| {
|
||||
let fle = try!(store
|
||||
.create(ModuleEntryPath::new(path_hash))
|
||||
.map_err(Box::new)
|
||||
|
|
Loading…
Reference in a new issue