Add "verify" feature in imag-store
This commit is contained in:
parent
6b1fdfbc1d
commit
555ea158aa
4 changed files with 23 additions and 0 deletions
|
@ -12,6 +12,8 @@ toml = "0.1.25"
|
|||
|
||||
[dependencies.libimagstore]
|
||||
path = "../libimagstore"
|
||||
default-features = false
|
||||
features = ["verify"]
|
||||
|
||||
[dependencies.libimagrt]
|
||||
path = "../libimagrt"
|
||||
|
|
|
@ -33,6 +33,7 @@ mod get;
|
|||
mod retrieve;
|
||||
mod ui;
|
||||
mod update;
|
||||
mod verify;
|
||||
mod util;
|
||||
|
||||
use create::create;
|
||||
|
@ -41,6 +42,7 @@ use get::get;
|
|||
use retrieve::retrieve;
|
||||
use ui::build_ui;
|
||||
use update::update;
|
||||
use verify::verify;
|
||||
|
||||
fn main() {
|
||||
let rt = generate_runtime_setup("imag-store",
|
||||
|
@ -63,6 +65,7 @@ fn main() {
|
|||
"get" => get(&rt),
|
||||
"retrieve" => retrieve(&rt),
|
||||
"update" => update(&rt),
|
||||
"verify" => verify(&rt),
|
||||
_ => {
|
||||
debug!("Unknown command");
|
||||
// More error handling
|
||||
|
|
|
@ -181,4 +181,9 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
|||
.help("Remove Store Entry with this path. Root (/) is the store itself")
|
||||
.value_name("PATH"))
|
||||
)
|
||||
|
||||
.subcommand(SubCommand::with_name("verify")
|
||||
.about("Verify the store")
|
||||
.version("0.1")
|
||||
)
|
||||
}
|
||||
|
|
13
imag-store/src/verify.rs
Normal file
13
imag-store/src/verify.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
use std::process::exit;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
|
||||
pub fn verify(rt: &Runtime) {
|
||||
if rt.store().verify() {
|
||||
info!("Store seems to be fine");
|
||||
} else {
|
||||
warn!("Store seems to be broken somehow");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue