Merge branch 'convert-id-in-collection-command' into master

This commit is contained in:
Matthias Beyer 2019-11-02 17:49:55 +01:00
commit 8270646283
5 changed files with 103 additions and 30 deletions

View file

@ -38,3 +38,10 @@ features = ["color", "suggestions", "wrap_help"]
[dev-dependencies] [dev-dependencies]
env_logger = "0.7" env_logger = "0.7"
[lib]
name = "libimagidincollectioncmd"
path = "src/lib.rs"
[[bin]]
name = "imag-id-in-collection"
path = "src/bin.rs"

View file

@ -0,0 +1,40 @@
//
// 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
//
#![forbid(unsafe_code)]
#![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 libimagrt;
simple_imag_application_binary!(libimagidincollectioncmd, ImagIdInCollection);

View file

@ -46,7 +46,7 @@ extern crate env_logger;
extern crate libimagerror; extern crate libimagerror;
extern crate libimagstore; extern crate libimagstore;
#[macro_use] extern crate libimagrt; extern crate libimagrt;
use std::io::Write; use std::io::Write;
@ -54,9 +54,11 @@ use filters::filter::Filter;
use failure::Fallible as Result; use failure::Fallible as Result;
use failure::Error; use failure::Error;
use failure::err_msg; use failure::err_msg;
use clap::App;
use libimagstore::storeid::StoreId; use libimagstore::storeid::StoreId;
use libimagrt::setup::generate_runtime_setup; use libimagrt::application::ImagApplication;
use libimagrt::runtime::Runtime;
mod ui; mod ui;
@ -83,12 +85,13 @@ impl<'a, A> Filter<StoreId> for IsInCollectionsFilter<'a, A>
} }
fn main() -> Result<()> { /// Marker enum for implementing ImagApplication on
let version = make_imag_version!(); ///
let rt = generate_runtime_setup("imag-id-in-collection", /// This is used by binaries crates to execute business logic
&version, /// or to build a CLI completion.
"filter ids by collection", pub enum ImagIdInCollection {}
crate::ui::build_ui); impl ImagApplication for ImagIdInCollection {
fn run(rt: Runtime) -> Result<()> {
let values = rt let values = rt
.cli() .cli()
.values_of("in-collection-filter") .values_of("in-collection-filter")
@ -113,5 +116,21 @@ fn main() -> Result<()> {
rt.report_touched(&id).map_err(Error::from) rt.report_touched(&id).map_err(Error::from)
}) })
.collect() .collect()
} }
fn build_cli<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
ui::build_ui(app)
}
fn name() -> &'static str {
env!("CARGO_PKG_NAME")
}
fn description() -> &'static str {
"print all ids"
}
fn version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
}

View file

@ -29,6 +29,7 @@ imag-diagnostics = { optional = true, path = "../imag-diagnostics" }
imag-edit = { optional = true, path = "../imag-edit" } imag-edit = { optional = true, path = "../imag-edit" }
imag-gps = { optional = true, path = "../imag-gps" } imag-gps = { optional = true, path = "../imag-gps" }
imag-grep = { optional = true, path = "../imag-grep" } imag-grep = { optional = true, path = "../imag-grep" }
imag-id-in-collection = { optional = true, path = "../imag-id-in-collection" }
imag-ids = { optional = true, path = "../imag-ids" } imag-ids = { optional = true, path = "../imag-ids" }
imag-init = { optional = true, path = "../imag-init" } imag-init = { optional = true, path = "../imag-init" }
imag-link = { optional = true, path = "../imag-link" } imag-link = { optional = true, path = "../imag-link" }
@ -86,6 +87,7 @@ cc-all = [
"cc-imag-edit", "cc-imag-edit",
"cc-imag-gps", "cc-imag-gps",
"cc-imag-grep", "cc-imag-grep",
"cc-imag-id-in-collection",
"cc-imag-ids", "cc-imag-ids",
"cc-imag-init", "cc-imag-init",
"cc-imag-link", "cc-imag-link",
@ -112,6 +114,7 @@ cc-imag-diagnostics = [ "imag-diagnostics" ]
cc-imag-edit = [ "imag-edit" ] cc-imag-edit = [ "imag-edit" ]
cc-imag-gps = [ "imag-gps" ] cc-imag-gps = [ "imag-gps" ]
cc-imag-grep = [ "imag-grep" ] cc-imag-grep = [ "imag-grep" ]
cc-imag-id-in-collection = [ "imag-id-in-collection" ]
cc-imag-ids = [ "imag-ids" ] cc-imag-ids = [ "imag-ids" ]
cc-imag-init = [ "imag-init" ] cc-imag-init = [ "imag-init" ]
cc-imag-link = [ "imag-link" ] cc-imag-link = [ "imag-link" ]

View file

@ -40,6 +40,8 @@ extern crate libimageditcmd;
extern crate libimaggpscmd; extern crate libimaggpscmd;
#[cfg(feature = "cc-imag-grep")] #[cfg(feature = "cc-imag-grep")]
extern crate libimaggrepcmd; extern crate libimaggrepcmd;
#[cfg(feature = "cc-imag-id-in-collection")]
extern crate libimagidincollectioncmd;
#[cfg(feature = "cc-imag-ids")] #[cfg(feature = "cc-imag-ids")]
extern crate libimagidscmd; extern crate libimagidscmd;
#[cfg(feature = "cc-imag-init")] #[cfg(feature = "cc-imag-init")]
@ -119,6 +121,8 @@ fn main() {
let app = app.subcommand(build_subcommand!("gps", libimaggpscmd, ImagGps)); let app = app.subcommand(build_subcommand!("gps", libimaggpscmd, ImagGps));
#[cfg(feature = "cc-imag-grep")] #[cfg(feature = "cc-imag-grep")]
let app = app.subcommand(build_subcommand!("grep", libimaggrepcmd, ImagGrep)); let app = app.subcommand(build_subcommand!("grep", libimaggrepcmd, ImagGrep));
#[cfg(feature = "cc-imag-id-in-collection")]
let app = app.subcommand(build_subcommand!("id-in-colleciton", libimagidincollectioncmd, ImagIdInCollection));
#[cfg(feature = "cc-imag-ids")] #[cfg(feature = "cc-imag-ids")]
let app = app.subcommand(build_subcommand!("ids", libimagidscmd, ImagIds)); let app = app.subcommand(build_subcommand!("ids", libimagidscmd, ImagIds));
#[cfg(feature = "cc-imag-init")] #[cfg(feature = "cc-imag-init")]