imag/bin/core/imag-store/src/main.rs

109 lines
2.9 KiB
Rust
Raw Normal View History

//
// 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
//
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;
#[macro_use] extern crate error_chain;
2016-01-23 14:38:14 +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-03 20:00:34 +00:00
#[cfg(not(test))]
extern crate libimagutil;
use libimagrt::setup::generate_runtime_setup;
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;
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;
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;
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() {
let version = make_imag_version!();
2017-06-18 16:57:15 +00:00
let mut rt = generate_runtime_setup("imag-store",
&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),
other => {
2017-06-18 18:00:47 +00:00
debug!("Unknown command");
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