init
This commit is contained in:
parent
1456b67aa1
commit
95534c1621
@ -13,7 +13,16 @@ impl CompareMode {
|
||||
pub fn new(args: Vec<String>, in_path: String, out_path: String) -> CompareMode {
|
||||
|
||||
|
||||
CompareMode { in_path, out_path, args, snapshot: Default::default() }
|
||||
CompareMode {
|
||||
left: Default::default(),
|
||||
right: Default::default(),
|
||||
args,
|
||||
results: SnapshotCompareResult {
|
||||
created: vec![],
|
||||
deleted: vec![],
|
||||
changed: vec![],
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ pub mod comparemode;
|
||||
|
||||
use std::env::args;
|
||||
use crate::syscompare::{SysCompareApp};
|
||||
use crate::syscompare::CompareMode::{Compare, Create};
|
||||
use crate::syscompare::SysCompareMode::{Compare, Create};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = args().collect();
|
||||
|
@ -2,61 +2,67 @@ use std::collections::HashMap;
|
||||
use std::env::args;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use Fasching::snapshot::Snapshot;
|
||||
use crate::comparemode::CompareMode;
|
||||
use crate::createmode::CreateMode;
|
||||
|
||||
pub enum CompareMode {
|
||||
pub enum SysCompareMode {
|
||||
Create,
|
||||
Compare
|
||||
}
|
||||
|
||||
pub struct SysCompareApp {
|
||||
mode: CompareMode,
|
||||
mode: SysCompareMode,
|
||||
args: Vec<String>,
|
||||
comparatives: Arc<Mutex<HashMap<String, Snapshot>>>
|
||||
}
|
||||
|
||||
|
||||
impl SysCompareApp {
|
||||
pub fn new(mode: CompareMode, args: Vec<String>) -> SysCompareApp {
|
||||
pub fn new(mode: SysCompareMode, args: Vec<String>) -> SysCompareApp {
|
||||
SysCompareApp { mode, args, comparatives: Arc::new(Mutex::new(HashMap::new())) }
|
||||
}
|
||||
pub fn run(&self) {
|
||||
println!("running");
|
||||
match self.mode {
|
||||
CompareMode::Create => {
|
||||
SysCompareMode::Create => {
|
||||
let in_path = match self.args.get(2) {
|
||||
None => {panic!("Missing hash dir path as second argument")}
|
||||
Some(r) => {
|
||||
if r.replace("./", "").is_empty() {
|
||||
panic!("Specify input file name")
|
||||
} else {
|
||||
r
|
||||
}
|
||||
}
|
||||
Some(r) => {not_empty(r)}
|
||||
};
|
||||
let out_path = match self.args.get(3) {
|
||||
None => {panic!("Missing output path as third argument")}
|
||||
Some(r) => {
|
||||
if r.replace("./", "").is_empty() {
|
||||
panic!("Specify out path file name")
|
||||
} else {
|
||||
r
|
||||
}
|
||||
}
|
||||
Some(r) => {not_empty(r)}
|
||||
};
|
||||
let create = CreateMode::new(self.args.clone(), in_path.clone(), out_path.clone());
|
||||
create.run()
|
||||
}
|
||||
CompareMode::Compare => {
|
||||
SysCompareMode::Compare => {
|
||||
let left = match self.args.get(2) {
|
||||
None => {panic!("Missing hash dir path as second argument")}
|
||||
Some(r) => {not_empty(r)}
|
||||
};
|
||||
let right = match self.args.get(3) {
|
||||
None => {panic!("Missing output path as third argument")}
|
||||
Some(r) => {not_empty(r)}
|
||||
};
|
||||
|
||||
let compare = CompareMode::new(self.args.clone(), left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn not_empty(r: &String) -> String {
|
||||
if r.replace("./", "").is_empty() {
|
||||
panic!("Specify input file name")
|
||||
} else {
|
||||
r.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SysCompareApp {
|
||||
fn default() -> Self {
|
||||
SysCompareApp { mode: CompareMode::Create, args: vec![], comparatives: Arc::new(Mutex::new(HashMap::new())) }
|
||||
SysCompareApp { mode: SysCompareMode::Create, args: vec![], comparatives: Arc::new(Mutex::new(HashMap::new())) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user