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;
|
2016-02-01 18:17:00 +00:00
|
|
|
extern crate semver;
|
2016-01-23 14:38:14 +00:00
|
|
|
extern crate toml;
|
|
|
|
#[macro_use] extern crate version;
|
|
|
|
|
|
|
|
extern crate libimagrt;
|
|
|
|
extern crate libimagstore;
|
|
|
|
extern crate libimagutil;
|
|
|
|
|
2016-01-23 15:29:04 +00:00
|
|
|
use libimagrt::runtime::Runtime;
|
|
|
|
use std::process::exit;
|
|
|
|
|
2016-01-24 19:19:56 +00:00
|
|
|
mod error;
|
2016-01-23 15:01:17 +00:00
|
|
|
mod ui;
|
2016-01-23 15:29:04 +00:00
|
|
|
mod create;
|
2016-01-25 19:09:48 +00:00
|
|
|
mod retrieve;
|
2016-01-23 15:29:04 +00:00
|
|
|
mod update;
|
|
|
|
mod delete;
|
2016-01-28 18:40:58 +00:00
|
|
|
mod util;
|
2016-01-23 15:01:17 +00:00
|
|
|
|
|
|
|
use ui::build_ui;
|
2016-01-23 15:29:04 +00:00
|
|
|
use create::create;
|
2016-01-25 19:09:48 +00:00
|
|
|
use retrieve::retrieve;
|
2016-01-23 15:29:04 +00:00
|
|
|
use update::update;
|
|
|
|
use delete::delete;
|
2016-01-23 15:01:17 +00:00
|
|
|
|
2016-01-23 14:35:31 +00:00
|
|
|
fn main() {
|
2016-01-23 15:29:04 +00:00
|
|
|
let name = "imag-store";
|
|
|
|
let version = &version!()[..];
|
|
|
|
let about = "Direct interface to the store. Use with great care!";
|
|
|
|
let ui = build_ui(Runtime::get_default_cli_builder(name, version, about));
|
|
|
|
let rt = {
|
|
|
|
let rt = Runtime::new(ui);
|
|
|
|
if rt.is_ok() {
|
|
|
|
rt.unwrap()
|
|
|
|
} else {
|
|
|
|
println!("Could not set up Runtime");
|
2016-04-17 19:07:39 +00:00
|
|
|
println!("{:?}", rt.unwrap_err());
|
2016-01-23 15:29:04 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
rt.cli()
|
|
|
|
.subcommand_name()
|
|
|
|
.map_or_else(
|
|
|
|
|| {
|
|
|
|
debug!("No command");
|
|
|
|
// More error handling
|
|
|
|
},
|
|
|
|
|name| {
|
|
|
|
debug!("Call: {}", name);
|
|
|
|
match name {
|
|
|
|
"create" => create(&rt),
|
2016-01-25 19:09:48 +00:00
|
|
|
"retrieve" => retrieve(&rt),
|
2016-01-23 15:29:04 +00:00
|
|
|
"update" => update(&rt),
|
|
|
|
"delete" => delete(&rt),
|
|
|
|
_ => {
|
|
|
|
debug!("Unknown command");
|
|
|
|
// More error handling
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)
|
2016-01-23 14:35:31 +00:00
|
|
|
}
|
2016-01-23 15:29:04 +00:00
|
|
|
|