wip clip
This commit is contained in:
parent
ec6abc9050
commit
feecfb4948
@ -7,5 +7,6 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
Fasching = "0.1.19"
|
Fasching = "0.1.19"
|
||||||
|
clap = { version = "4.5.4", features = ["derive"] }
|
||||||
#Fasching = {path = "../Fasching/"}
|
#Fasching = {path = "../Fasching/"}
|
||||||
whoami = "1.5.1"
|
whoami = "1.5.1"
|
||||||
|
34
src/main.rs
34
src/main.rs
@ -1,35 +1,43 @@
|
|||||||
pub mod comparemode;
|
pub mod comparemode;
|
||||||
pub mod createmode;
|
pub mod createmode;
|
||||||
pub mod syscompare;
|
pub mod syscompare;
|
||||||
|
mod options;
|
||||||
|
|
||||||
use crate::syscompare::SysCompareApp;
|
use crate::syscompare::SysCompareApp;
|
||||||
use crate::syscompare::SysCompareMode::{Compare, Create};
|
use crate::syscompare::SysCompareMode::{Compare, Create};
|
||||||
use std::env::args;
|
use std::env::args;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
use clap::{FromArgMatches, Parser};
|
||||||
|
use crate::options::{Arguments, Commands};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let options = Arguments::parse();
|
||||||
|
|
||||||
let args: Vec<String> = args().collect();
|
let args: Vec<String> = args().collect();
|
||||||
// println!("{:#?}", args); // testing
|
// println!("{:#?}", args); // testing
|
||||||
|
|
||||||
let app = match args.get(1) {
|
let app = match options.command {
|
||||||
None => {
|
None => {
|
||||||
print_help();
|
print_help();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
Some(mode) => {
|
Some(Commands::Create { root_dir, output_path }) => {
|
||||||
// app mode
|
// app mode
|
||||||
let m = mode.as_str();
|
|
||||||
let app_mode = match m {
|
|
||||||
"create" => Create,
|
|
||||||
"compare" => Compare,
|
|
||||||
_ => {
|
|
||||||
println!("Invalid MODE argument");
|
|
||||||
print_help();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SysCompareApp::new(app_mode, args)
|
// let app_mode = match m {
|
||||||
|
// "create" => Create,
|
||||||
|
// "compare" => Compare,
|
||||||
|
// _ => {
|
||||||
|
// println!("Invalid MODE argument");
|
||||||
|
// print_help();
|
||||||
|
// exit(0);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
SysCompareApp::new(Create, args)
|
||||||
|
},
|
||||||
|
Some(Commands::Compare { left, right }) => {
|
||||||
|
SysCompareApp::new(Compare, args)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
27
src/options.rs
Normal file
27
src/options.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
use clap::{Command, Parser, Subcommand};
|
||||||
|
use crate::syscompare::SysCompareMode;
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
pub struct Arguments {
|
||||||
|
#[command(subcommand)]
|
||||||
|
pub command: Option<Commands>,
|
||||||
|
pub input_path: Option<String>,
|
||||||
|
pub output_path: Option<String>,
|
||||||
|
pub show: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum Commands {
|
||||||
|
Create {
|
||||||
|
#[arg(short, long)]
|
||||||
|
root_dir: String,
|
||||||
|
#[arg(short, long)]
|
||||||
|
output_path: String,
|
||||||
|
},
|
||||||
|
Compare {
|
||||||
|
#[arg(short, long)]
|
||||||
|
left: String,
|
||||||
|
#[arg(short, long)]
|
||||||
|
right: String,
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user