diff options
76 files changed, 1683 insertions, 177 deletions
diff --git a/.travis.yml b/.travis.yml index 9dbfe469..d6a4b0b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,35 @@ dist: language: rust -rust: - - 1.23.0 - - 1.24.0 - - stable +matrix: + include: + - language: nix + script: + - bash ./scripts/find-dead-symlinks + - bash ./scripts/license-headers-updated + - bash ./scripts/branch-contains-no-tmp-commits + - language: rust + rust: 1.23.0 + cache: + cargo: true + script: + - cargo build --all --all-features -j 1 || exit 1 + - cargo test --all --all-features -j 1 || exit 1 + - language: rust + rust: 1.24.0 + cache: + cargo: true + script: + - cargo build --all --all-features -j 1 || exit 1 + - cargo test --all --all-features -j 1 || exit 1 + - language: rust + rust: stable + cache: + cargo: true + script: + - cargo build --all --all-features -j 1 || exit 1 + - cargo test --all --all-features -j 1 || exit 1 -cache: - cargo: true addons: apt: @@ -21,13 +43,6 @@ addons: - libdbus-1-dev - pkg-config -script: - - | - bash ./scripts/find-dead-symlinks || exit 1 - bash ./scripts/license-headers-updated || exit 1 - cargo build --all --all-features -j 1 || exit 1 - cargo test --all --all-features -j 1 || exit 1 - notifications: email: on_success: never @@ -23,6 +23,7 @@ members = [ "bin/domain/imag-notes", "bin/domain/imag-timetrack", "bin/domain/imag-todo", + "bin/domain/imag-wiki", "lib/core/libimagerror", "lib/core/libimagrt", "lib/core/libimagstore", @@ -35,6 +36,7 @@ members = [ "lib/domain/libimagnotes", "lib/domain/libimagtimetrack", "lib/domain/libimagtodo", + "lib/domain/libimagwiki", "lib/entry/libimagentryannotation", "lib/entry/libimagentrycategory", "lib/entry/libimagentrydatetime", diff --git a/bin/core/imag-annotate/Cargo.toml b/bin/core/imag-annotate/Cargo.toml index 5cd4f6fc..b3e48753 100644 --- a/bin/core/imag-annotate/Cargo.toml +++ b/bin/core/imag-annotate/Cargo.toml @@ -35,7 +35,7 @@ libimagentryedit = { version = "0.7.0", path = "../../../lib/entry/libimag libimagutil = { version = "0.7.0", path = "../../../lib/etc/libimagutil" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["color", "suggestions"] +features = ["color", "suggestions", "wrap_help"] diff --git a/bin/core/imag-annotate/src/main.rs b/bin/core/imag-annotate/src/main.rs index d196c7cb..ddeecf90 100644 --- a/bin/core/imag-annotate/src/main.rs +++ b/bin/core/imag-annotate/src/main.rs @@ -79,7 +79,7 @@ fn main() { let _ = rt.handle_unknown_subcommand("imag-annotation", other, rt.cli()) .map_err_trace_exit_unwrap(1) .code() - .map(std::process::exit); + .map(::std::process::exit); }, } }); diff --git a/bin/core/imag-diagnostics/Cargo.toml b/bin/core/imag-diagnostics/Cargo.toml index 36150006..fc4230ab 100644 --- a/bin/core/imag-diagnostics/Cargo.toml +++ b/bin/core/imag-diagnostics/Cargo.toml @@ -25,7 +25,7 @@ libimagerror = { version = "0.7.0", path = "../../../lib/core/libimagerror" libimagentrylink = { version = "0.7.0", path = "../../../lib/entry/libimagentrylink" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["suggestions", "color"] +features = ["suggestions", "color", "wrap_help"] diff --git a/bin/core/imag-edit/Cargo.toml b/bin/core/imag-edit/Cargo.toml index caeed1db..bccd113b 100644 --- a/bin/core/imag-edit/Cargo.toml +++ b/bin/core/imag-edit/Cargo.toml @@ -34,9 +34,9 @@ libimagutil = { version = "0.7.0", path = "../../../lib/etc/libimagutil" } libimagentryedit = { version = "0.7.0", path = "../../../lib/entry/libimagentryedit" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["color", "suggestions"] +features = ["color", "suggestions", "wrap_help"] [dev-dependencies.libimagutil] version = "0.7.0" diff --git a/bin/core/imag-gps/Cargo.toml b/bin/core/imag-gps/Cargo.toml index 85cd23ee..96b72ae0 100644 --- a/bin/core/imag-gps/Cargo.toml +++ b/bin/core/imag-gps/Cargo.toml @@ -34,9 +34,9 @@ libimagentrygps = { version = "0.7.0", path = "../../../lib/entry/libimagentryg libimagutil = { version = "0.7.0", path = "../../../lib/etc/libimagutil" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["color", "suggestions"] +features = ["color", "suggestions", "wrap_help"] [dev-dependencies.libimagutil] version = "0.7.0" diff --git a/bin/core/imag-grep/Cargo.toml b/bin/core/imag-grep/Cargo.toml index 918c534b..13d215bb 100644 --- a/bin/core/imag-grep/Cargo.toml +++ b/bin/core/imag-grep/Cargo.toml @@ -30,7 +30,7 @@ libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" } libimagerror = { version = "0.7.0", path = "../../../lib/core/libimagerror" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["color", "suggestions"] +features = ["color", "suggestions", "wrap_help"] diff --git a/bin/core/imag-grep/src/main.rs b/bin/core/imag-grep/src/main.rs index 1f97e4a2..223849c9 100644 --- a/bin/core/imag-grep/src/main.rs +++ b/bin/core/imag-grep/src/main.rs @@ -120,6 +120,7 @@ fn show(rt: &Runtime, e: &Entry, re: &Regex, opts: &Options, count: &mut usize) } let _ = writeln!(rt.stdout(), "").to_exit_code().unwrap_or_exit(); + *count += 1; } } diff --git a/bin/core/imag-ids/Cargo.toml b/bin/core/imag-ids/Cargo.toml index 591c190f..68ea7cb4 100644 --- a/bin/core/imag-ids/Cargo.toml +++ b/bin/core/imag-ids/Cargo.toml @@ -22,12 +22,14 @@ is-it-maintained-open-issues = { repository = "matthiasbeyer/imag" } maintenance = { status = "actively-developed" } [dependencies] +filters = "0.2" + libimagstore = { version = "0.7.0", path = "../../../lib/core/libimagstore" } libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" } libimagerror = { version = "0.7.0", path = "../../../lib/core/libimagerror" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["color", "suggestions"] +features = ["color", "suggestions", "wrap_help"] diff --git a/bin/core/imag-ids/src/main.rs b/bin/core/imag-ids/src/main.rs index 30e0c49f..08beb465 100644 --- a/bin/core/imag-ids/src/main.rs +++ b/bin/core/imag-ids/src/main.rs @@ -33,6 +33,7 @@ )] extern crate clap; +extern crate filters; extern crate libimagerror; extern crate libimagstore; @@ -40,23 +41,30 @@ extern crate libimagstore; use std::io::Write; -use clap::{Arg, App}; +use filters::filter::Filter; use libimagrt::setup::generate_runtime_setup; use libimagerror::trace::MapErrTrace; use libimagerror::exit::ExitUnwrap; use libimagerror::io::ToExitCode; +use libimagstore::storeid::StoreId; +mod ui; +use ui::build_ui; -/// No special CLI -pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { - app - .arg(Arg::with_name("print-storepath") - .long("with-storepath") - .takes_value(false) - .required(false) - .multiple(false) - .help("Print the storepath for each id")) + +pub struct IsInCollectionsFilter<'a, A>(Option<A>, ::std::marker::PhantomData<&'a str>) + where A: AsRef<[&'a str]>; + +impl<'a, A> Filter<StoreId> for IsInCollectionsFilter<'a, A> + where A: AsRef<[&'a str]> + 'a +{ + fn filter(&self, sid: &StoreId) -> bool { + match self.0 { + Some(ref colls) => sid.is_in_collection(colls), + None => true, + } + } } fn main() { @@ -68,9 +76,17 @@ fn main() { let print_storepath = rt.cli().is_present("print-storepath"); + let values = rt + .cli() + .values_of("in-collection-filter") + .map(|v| v.collect::<Vec<&str>>()); + + let collection_filter = IsInCollectionsFilter(values, ::std::marker::PhantomData); + rt.store() .entries() .map_err_trace_exit_unwrap(1) + .filter(|id| collection_filter.filter(id)) .map(|id| if print_storepath { id } else { diff --git a/bin/core/imag-ids/src/ui.rs b/bin/core/imag-ids/src/ui.rs new file mode 100644 index 00000000..000539dd --- /dev/null +++ b/bin/core/imag-ids/src/ui.rs @@ -0,0 +1,40 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015-2018 Matthias Beyer <mail@beyermatthias.de> and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + +use clap::{Arg, App}; + +pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { + app + .arg(Arg::with_name("print-storepath") + .long("with-storepath") + .takes_value(false) + .required(false) + .multiple(false) + .help("Print the storepath for each id")) + + .arg(Arg::with_name("in-collection-filter") + .long("in-collection") + .short("c") + .required(false) + .takes_value(true) + .multiple(true) + .value_names(&["COLLECTION"]) + .help("Filter for ids which are only in these collections")) +} + diff --git a/bin/core/imag-init/Cargo.toml b/bin/core/imag-init/Cargo.toml index 5d96bd16..a17b480e 100644 --- a/bin/core/imag-init/Cargo.toml +++ b/bin/core/imag-init/Cargo.toml @@ -26,9 +26,9 @@ libimagerror = { version = "0.7.0", path = "../../../lib/core/libimagerror" } libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["color", "suggestions"] +features = ["color", "suggestions", "wrap_help"] [dev-dependencies] toml = "0.4" diff --git a/bin/core/imag-init/src/main.rs b/bin/core/imag-init/src/main.rs index 2ad15725..de809128 100644 --- a/bin/core/imag-init/src/main.rs +++ b/bin/core/imag-init/src/main.rs @@ -50,6 +50,7 @@ use std::process::Command; use libimagerror::exit::ExitUnwrap; use libimagerror::io::ToExitCode; +use libimagrt::runtime::Runtime; const CONFIGURATION_STR : &'static str = include_str!("../imagrc.toml"); @@ -68,7 +69,10 @@ imagrc.toml fn main() { let version = make_imag_version!(); - let app = ui::build_ui(&version); + let app = ui::build_ui(Runtime::get_default_cli_builder( + "imag-init", + version.as_str(), + "Intializes the imag store, optionally with git")); let matches = app.get_matches(); let mut out = ::std::io::stdout(); diff --git a/bin/core/imag-init/src/ui.rs b/bin/core/imag-init/src/ui.rs index ff985290..7936cc9b 100644 --- a/bin/core/imag-init/src/ui.rs +++ b/bin/core/imag-init/src/ui.rs @@ -19,12 +19,8 @@ use clap::{Arg, App}; -pub fn build_ui<'a>(version: &'a str) -> App<'a, 'a> { - App::new("imag-init") - .version(version) - .author("Matthias Beyer <mail@beyermatthias.de>") - .about("Initialize a ~/.imag repository. Optionally with git") - +pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { + app .arg(Arg::with_name("devel") .long("dev") .takes_value(false) diff --git a/bin/core/imag-link/Cargo.toml b/bin/core/imag-link/Cargo.toml index d3553c56..5bec1e9d 100644 --- a/bin/core/imag-link/Cargo.toml +++ b/bin/core/imag-link/Cargo.toml @@ -35,9 +35,9 @@ libimagentrylink = { version = "0.7.0", path = "../../../lib/entry/libimagentryl libimagutil = { version = "0.7.0", path = "../../../lib/etc/libimagutil" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false -features = ["color", "suggestions"] +features = ["color", "suggestions", "wrap_help"] [dev-dependencies] env_logger = "0.5" diff --git a/bin/core/imag-mv/Cargo.toml b/bin/core/imag-mv/Cargo.toml index de49a08b..19e0913e 100644 --- a/bin/core/imag-mv/Cargo.toml +++ b/bin/core/imag-mv/Cargo.toml @@ -30,7 +30,7 @@ libimagstore = { version = "0.7.0", path = "../../../lib/core/libimagstore" libimagentrylink = { version = "0.7.0", path = "../../../lib/entry/libimagentrylink" } [dependencies.clap] -version = ">=2.29" +version = "^2.29" default-features = false |