2016-10-01 15:35:06 +00:00
|
|
|
//
|
|
|
|
// imag - the personal information management suite for the commandline
|
2018-02-07 01:48:53 +00:00
|
|
|
// Copyright (C) 2015-2018 Matthias Beyer <mail@beyermatthias.de> and contributors
|
2016-10-01 15:35:06 +00:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
|
2016-04-21 11:27:05 +00:00
|
|
|
#![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,
|
|
|
|
)]
|
|
|
|
|
2016-01-23 14:38:14 +00:00
|
|
|
extern crate clap;
|
|
|
|
#[macro_use] extern crate log;
|
|
|
|
extern crate toml;
|
2017-09-03 20:00:34 +00:00
|
|
|
#[cfg(test)] extern crate toml_query;
|
2017-08-31 19:37:52 +00:00
|
|
|
#[macro_use] extern crate error_chain;
|
2016-01-23 14:38:14 +00:00
|
|
|
|
2018-01-31 10:09:00 +00:00
|
|
|
#[macro_use] extern crate libimagrt;
|
2016-01-23 14:38:14 +00:00
|
|
|
extern crate libimagstore;
|
2017-09-03 18:41:43 +00:00
|
|
|
extern crate libimagerror;
|
2016-01-23 14:38:14 +00:00
|
|
|
|
2017-09-03 20:00:34 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate libimagutil;
|
2017-09-04 21:02:45 +00:00
|
|
|
|
2017-09-03 20:00:34 +00:00
|
|
|
#[cfg(not(test))]
|
|
|
|
extern crate libimagutil;
|
|
|
|
|
2016-05-18 17:06:05 +00:00
|
|
|
use libimagrt::setup::generate_runtime_setup;
|
2018-04-04 15:01:02 +00:00
|
|
|
use libimagerror::trace::MapErrTrace;
|
2016-01-23 15:29:04 +00:00
|
|
|
|
|
|
|
mod create;
|
2016-05-27 09:26:22 +00:00
|
|
|
mod delete;
|
2017-06-18 18:00:47 +00:00
|
|
|
mod dump;
|
2016-05-27 09:26:22 +00:00
|
|
|
mod error;
|
|
|
|
mod get;
|
2016-01-25 19:09:48 +00:00
|
|
|
mod retrieve;
|
2016-05-27 09:26:22 +00:00
|
|
|
mod ui;
|
2016-01-23 15:29:04 +00:00
|
|
|
mod update;
|
2016-07-16 22:45:51 +00:00
|
|
|
mod verify;
|
2016-01-28 18:40:58 +00:00
|
|
|
mod util;
|
2016-01-23 15:01:17 +00:00
|
|
|
|
2017-06-18 18:00:47 +00:00
|
|
|
use std::ops::Deref;
|
|
|
|
|
2016-01-23 15:29:04 +00:00
|
|
|
use create::create;
|
2016-05-27 09:26:22 +00:00
|
|
|
use delete::delete;
|
2017-06-18 18:00:47 +00:00
|
|
|
use dump::dump;
|
2016-05-27 09:26:22 +00:00
|
|
|
use get::get;
|
2016-01-25 19:09:48 +00:00
|
|
|
use retrieve::retrieve;
|
2016-05-27 09:26:22 +00:00
|
|
|
use ui::build_ui;
|
2016-01-23 15:29:04 +00:00
|
|
|
use update::update;
|
2016-07-16 22:45:51 +00:00
|
|
|
use verify::verify;
|
2016-01-23 15:01:17 +00:00
|
|
|
|
2016-01-23 14:35:31 +00:00
|
|
|
fn main() {
|
2018-01-31 10:09:00 +00:00
|
|
|
let version = make_imag_version!();
|
2017-06-18 16:57:15 +00:00
|
|
|
let mut rt = generate_runtime_setup("imag-store",
|
2018-01-31 10:09:00 +00:00
|
|
|
&version,
|
2017-06-18 16:57:15 +00:00
|
|
|
"Direct interface to the store. Use with great care!",
|
|
|
|
build_ui);
|
2016-01-23 15:29:04 +00:00
|
|
|
|
2017-06-18 18:00:47 +00:00
|
|
|
let command = rt.cli().subcommand_name().map(String::from);
|
|
|
|
|
|
|
|
if let Some(command) = command {
|
|
|
|
debug!("Call: {}", command);
|
|
|
|
match command.deref() {
|
|
|
|
"create" => create(&rt),
|
|
|
|
"delete" => delete(&rt),
|
|
|
|
"get" => get(&rt),
|
|
|
|
"retrieve" => retrieve(&rt),
|
|
|
|
"update" => update(&rt),
|
|
|
|
"verify" => verify(&rt),
|
|
|
|
"dump" => dump(&mut rt),
|
2018-04-04 15:01:02 +00:00
|
|
|
other => {
|
2017-06-18 18:00:47 +00:00
|
|
|
debug!("Unknown command");
|
2018-04-04 15:01:02 +00:00
|
|
|
let _ = rt.handle_unknown_subcommand("imag-store", other, rt.cli())
|
|
|
|
.map_err_trace_exit_unwrap(1)
|
|
|
|
.code()
|
2018-04-13 22:57:15 +00:00
|
|
|
.map(::std::process::exit);
|
2016-01-23 15:29:04 +00:00
|
|
|
},
|
2017-06-18 18:00:47 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
debug!("No command");
|
|
|
|
}
|
2016-01-23 14:35:31 +00:00
|
|
|
}
|
2016-01-23 15:29:04 +00:00
|
|
|
|