This commit is contained in:
Robin Appelman 2022-10-23 16:16:20 +02:00
commit e578513fdd
2 changed files with 22 additions and 4 deletions

View file

@ -1,5 +1,5 @@
use clap::Parser; use clap::Parser;
use edit::{edit_inner, EditOptions}; use edit::{edit_inner, EditOptions, TickRange};
use std::fs; use std::fs;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -9,12 +9,30 @@ struct Args {
path: String, path: String,
#[arg(long)] #[arg(long)]
unlock_pov: bool, unlock_pov: bool,
#[arg(long)]
from: Option<u32>,
#[arg(long)]
to: Option<u32>,
}
impl Args {
fn get_options(&self) -> EditOptions {
EditOptions {
unlock_pov: self.unlock_pov,
cut: if let (Some(from), Some(to)) = (self.from, self.to) {
Some(TickRange { from: from.into(), to: to.into() })
} else {
None
},
..EditOptions::default()
}
}
} }
fn main() { fn main() {
let args = Args::parse(); let args: Args = Args::parse();
let options = args.get_options();
let file = fs::read(&args.path).unwrap(); let file = fs::read(&args.path).unwrap();
let output = edit_inner(&file, EditOptions::default()); let output = edit_inner(&file, options);
fs::write("out.dem", output).unwrap(); fs::write("out.dem", output).unwrap();
} }

View file

@ -19,7 +19,7 @@ use crate::clean::clean_demo;
use crate::cond::strip_cond; use crate::cond::strip_cond;
use crate::cut::cut; use crate::cut::cut;
use crate::mutate::{MutatorList, PacketMutator}; use crate::mutate::{MutatorList, PacketMutator};
pub use crate::options::EditOptions; pub use crate::options::{EditOptions, TickRange, CondOptions};
use crate::pov::unlock_pov; use crate::pov::unlock_pov;
extern crate web_sys; extern crate web_sys;