Remove in-collection filtering

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-07-28 10:49:47 +02:00
parent 109292c65a
commit 38021753a8
4 changed files with 0 additions and 68 deletions

View file

@ -20,7 +20,6 @@ is-it-maintained-open-issues = { repository = "matthiasbeyer/imag" }
maintenance = { status = "actively-developed" } maintenance = { status = "actively-developed" }
[dependencies] [dependencies]
filters = "0.3.0"
log = "0.4.6" log = "0.4.6"
toml = "0.5.1" toml = "0.5.1"
toml-query = "0.9.2" toml-query = "0.9.2"

View file

@ -1,45 +0,0 @@
//
// imag - the personal information management suite for the commandline
// Copyright (C) 2015-2019 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 filters::filter::Filter;
use libimagstore::storeid::StoreId;
pub struct IsInCollectionsFilter<'a, A>(Option<A>, ::std::marker::PhantomData<&'a str>)
where A: AsRef<[&'a str]>;
impl<'a, A> IsInCollectionsFilter<'a, A>
where A: AsRef<[&'a str]>
{
pub fn new(collections: Option<A>) -> Self {
IsInCollectionsFilter(collections, ::std::marker::PhantomData)
}
}
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,
}
}
}

View file

@ -35,7 +35,6 @@
)] )]
extern crate clap; extern crate clap;
extern crate filters;
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate toml; extern crate toml;
extern crate toml_query; extern crate toml_query;
@ -50,8 +49,6 @@ extern crate libimagstore;
use std::io::Write; use std::io::Write;
use filters::filter::Filter;
use libimagstore::storeid::StoreId; use libimagstore::storeid::StoreId;
use libimagrt::setup::generate_runtime_setup; use libimagrt::setup::generate_runtime_setup;
use libimagerror::trace::MapErrTrace; use libimagerror::trace::MapErrTrace;
@ -59,11 +56,9 @@ use libimagerror::iter::TraceIterator;
use libimagerror::exit::ExitUnwrap; use libimagerror::exit::ExitUnwrap;
use libimagerror::io::ToExitCode; use libimagerror::io::ToExitCode;
mod id_filters;
mod ui; mod ui;
use crate::ui::build_ui; use crate::ui::build_ui;
use crate::id_filters::IsInCollectionsFilter;
fn main() { fn main() {
let version = make_imag_version!(); let version = make_imag_version!();
@ -74,13 +69,6 @@ fn main() {
let print_storepath = rt.cli().is_present("print-storepath"); 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::new(values);
let iterator = if rt.ids_from_stdin() { let iterator = if rt.ids_from_stdin() {
debug!("Fetching IDs from stdin..."); debug!("Fetching IDs from stdin...");
let ids = rt let ids = rt
@ -97,7 +85,6 @@ fn main() {
as Box<Iterator<Item = Result<StoreId, _>>> as Box<Iterator<Item = Result<StoreId, _>>>
} }
.trace_unwrap_exit() .trace_unwrap_exit()
.filter(|id| collection_filter.filter(id))
.map(|id| if print_storepath { .map(|id| if print_storepath {
(Some(rt.store().path()), id) (Some(rt.store().path()), id)
} else { } else {

View file

@ -31,15 +31,6 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.required(false) .required(false)
.multiple(false) .multiple(false)
.help("Print the storepath for each id")) .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"))
} }
pub struct PathProvider; pub struct PathProvider;