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

98 lines
2.6 KiB
Rust
Raw Normal View History

//
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 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;
#[macro_use] extern crate version;
#[macro_use] extern crate error_chain;
2016-01-23 14:38:14 +00:00
extern crate libimagrt;
extern crate libimagstore;
extern crate libimagutil;
2017-09-03 18:41:43 +00:00
extern crate libimagerror;
2016-01-23 14:38:14 +00:00
use libimagrt::setup::generate_runtime_setup;
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() {
2017-06-18 16:57:15 +00:00
let mut rt = generate_runtime_setup("imag-store",
&version!()[..],
"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),
_ => {
debug!("Unknown command");
2016-01-23 15:29:04 +00:00
// More error handling
},
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