.
This commit is contained in:
parent
bc3f85cc85
commit
caf9f5140b
@ -1,4 +1,3 @@
|
|||||||
use crate::syscompare::Comparer;
|
|
||||||
use Fasching::snapshot::{Snapshot, SnapshotChangeType, SnapshotCompareResult};
|
use Fasching::snapshot::{Snapshot, SnapshotChangeType, SnapshotCompareResult};
|
||||||
use Fasching::{compare_snapshots, import_snapshot};
|
use Fasching::{compare_snapshots, import_snapshot};
|
||||||
use crate::options::Arguments;
|
use crate::options::Arguments;
|
||||||
@ -32,8 +31,8 @@ impl CompareMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Comparer for CompareMode {
|
impl CompareMode {
|
||||||
fn run(&mut self) {
|
pub(crate) fn run(&mut self) {
|
||||||
let selector = match &self.selection {
|
let selector = match &self.selection {
|
||||||
None => "none",
|
None => "none",
|
||||||
Some(r) => {
|
Some(r) => {
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
use crate::print_help;
|
|
||||||
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use Fasching::hasher::HashType;
|
|
||||||
use Fasching::hasher::HashType::BLAKE3;
|
use Fasching::hasher::HashType::BLAKE3;
|
||||||
use Fasching::snapshot::Snapshot;
|
use Fasching::snapshot::Snapshot;
|
||||||
use Fasching::{create_snapshot, export_snapshot};
|
use Fasching::{create_snapshot, export_snapshot};
|
||||||
use crate::options::Arguments;
|
|
||||||
use crate::syscompare::Comparer;
|
|
||||||
|
|
||||||
pub struct CreateMode {
|
pub struct CreateMode {
|
||||||
snapshot_path: String,
|
snapshot_path: String,
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -1,6 +1,5 @@
|
|||||||
pub mod comparemode;
|
pub mod comparemode;
|
||||||
pub mod createmode;
|
pub mod createmode;
|
||||||
pub mod syscompare;
|
|
||||||
mod options;
|
mod options;
|
||||||
|
|
||||||
|
|
||||||
@ -10,15 +9,12 @@ use clap::{FromArgMatches, Parser};
|
|||||||
use crate::comparemode::CompareMode;
|
use crate::comparemode::CompareMode;
|
||||||
use crate::createmode::CreateMode;
|
use crate::createmode::CreateMode;
|
||||||
use crate::options::{Arguments, Commands};
|
use crate::options::{Arguments, Commands};
|
||||||
use crate::syscompare::Comparer;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let options = Arguments::parse();
|
let options = Arguments::parse();
|
||||||
let movable = options.clone();
|
let movable = options.clone();
|
||||||
let args: Vec<String> = args().collect();
|
|
||||||
// println!("{:#?}", args); // testing
|
|
||||||
|
|
||||||
let app = match options.command {
|
let _app = match options.command {
|
||||||
None => {}
|
None => {}
|
||||||
Some(Commands::Create { root_dir, output_path }) => {
|
Some(Commands::Create { root_dir, output_path }) => {
|
||||||
let mut create =
|
let mut create =
|
||||||
@ -34,11 +30,6 @@ fn main() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_help() {
|
|
||||||
println!("### Create Snapshot\n## ./sys-compare create [snapshot] [root_dir]");
|
|
||||||
println!("### Compare Snapshots\n## ./sys-compare compare [.snap] [.snap] [created]|[deleted]|[changed]");
|
|
||||||
}
|
|
||||||
|
|
||||||
// #[cfg(test)]
|
// #[cfg(test)]
|
||||||
// mod tests {
|
// mod tests {
|
||||||
// #[test]
|
// #[test]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use clap::{Command, Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Parser, Clone, Debug)]
|
#[derive(Parser, Clone, Debug)]
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
use crate::comparemode::CompareMode;
|
|
||||||
use crate::createmode::CreateMode;
|
|
||||||
use crate::print_help;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::process::exit;
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use Fasching::snapshot::Snapshot;
|
|
||||||
use crate::options::Arguments;
|
|
||||||
|
|
||||||
pub enum SysCompareMode {
|
|
||||||
Create,
|
|
||||||
Compare,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SysCompareApp {
|
|
||||||
mode: SysCompareMode,
|
|
||||||
options: Arguments,
|
|
||||||
#[allow(unused)]
|
|
||||||
comparatives: Arc<Mutex<HashMap<String, Snapshot>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SysCompareApp {
|
|
||||||
pub fn new(mode: SysCompareMode, options: Arguments) -> SysCompareApp {
|
|
||||||
SysCompareApp {
|
|
||||||
mode,
|
|
||||||
options,
|
|
||||||
comparatives: Arc::new(Mutex::new(HashMap::new())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn run(&self) {
|
|
||||||
println!("running");
|
|
||||||
match self.mode {
|
|
||||||
SysCompareMode::Create => {
|
|
||||||
// let mut create =
|
|
||||||
// CreateMode::new(self.options.clone(), snapshot_path.clone(), root_dir.clone());
|
|
||||||
// create.run()
|
|
||||||
}
|
|
||||||
SysCompareMode::Compare => {
|
|
||||||
// let left = match self.args.get(2) {
|
|
||||||
// None => {
|
|
||||||
// println!("Missing hash dir path as second argument");
|
|
||||||
// print_help();
|
|
||||||
// exit(0);
|
|
||||||
// }
|
|
||||||
// Some(r) => not_empty(r),
|
|
||||||
// };
|
|
||||||
// let right = match self.args.get(3) {
|
|
||||||
// None => {
|
|
||||||
// println!("Missing output path as third argument");
|
|
||||||
// print_help();
|
|
||||||
// exit(0);
|
|
||||||
// }
|
|
||||||
// Some(r) => not_empty(r),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let mut compare = CompareMode::new(self.args.clone(), left, right);
|
|
||||||
// compare.run()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fn not_empty(r: &String) -> String {
|
|
||||||
// if r.replace("./", "").is_empty() {
|
|
||||||
// println!("Specify input file name");
|
|
||||||
// print_help();
|
|
||||||
// exit(0);
|
|
||||||
// } else {
|
|
||||||
// r.to_string()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
impl Default for SysCompareApp {
|
|
||||||
fn default() -> Self {
|
|
||||||
SysCompareApp {
|
|
||||||
mode: SysCompareMode::Create,
|
|
||||||
comparatives: Arc::new(Mutex::new(HashMap::new())),
|
|
||||||
options: Arguments {
|
|
||||||
command: None,
|
|
||||||
input_path: None,
|
|
||||||
output_path: None,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Comparer {
|
|
||||||
fn run(&mut self);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user