mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-04-24 19:25:34 +08:00
Added argument parsing
This commit is contained in:
parent
8af8c4856b
commit
3e04750334
@ -7,6 +7,7 @@ repository = "https://github.com/a2x/cs2-dumper"
|
||||
license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
log = "0.4"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
37
src/main.rs
37
src/main.rs
@ -3,6 +3,8 @@
|
||||
use std::fs;
|
||||
use std::time::Instant;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use simple_logger::SimpleLogger;
|
||||
|
||||
use builder::*;
|
||||
@ -17,9 +19,34 @@ mod error;
|
||||
mod remote;
|
||||
mod sdk;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[arg(long)]
|
||||
all: bool,
|
||||
|
||||
#[arg(short, long)]
|
||||
interfaces: bool,
|
||||
|
||||
#[arg(short, long)]
|
||||
offsets: bool,
|
||||
|
||||
#[arg(short, long)]
|
||||
schemas: bool,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
SimpleLogger::new().init().unwrap();
|
||||
|
||||
let Args {
|
||||
all,
|
||||
interfaces,
|
||||
offsets,
|
||||
schemas,
|
||||
} = Args::parse();
|
||||
|
||||
let start_time = Instant::now();
|
||||
|
||||
fs::create_dir_all("generated")?;
|
||||
|
||||
let process = Process::new("cs2.exe")?;
|
||||
@ -31,11 +58,19 @@ fn main() -> Result<()> {
|
||||
FileBuilderEnum::RustFileBuilder(RustFileBuilder),
|
||||
];
|
||||
|
||||
let start_time = Instant::now();
|
||||
let all = all || !(interfaces || offsets || schemas);
|
||||
|
||||
if schemas || all {
|
||||
dump_schemas(&mut builders, &process)?;
|
||||
}
|
||||
|
||||
if interfaces || all {
|
||||
dump_interfaces(&mut builders, &process)?;
|
||||
}
|
||||
|
||||
if offsets || all {
|
||||
dump_offsets(&mut builders, &process)?;
|
||||
}
|
||||
|
||||
let duration = start_time.elapsed();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user