mirror of
https://codeberg.org/demostf/edit.git
synced 2026-06-03 11:54:07 +02:00
cli
This commit is contained in:
parent
b74df4e965
commit
e578513fdd
2 changed files with 22 additions and 4 deletions
24
src/edit.rs
24
src/edit.rs
|
|
@ -1,5 +1,5 @@
|
|||
use clap::Parser;
|
||||
use edit::{edit_inner, EditOptions};
|
||||
use edit::{edit_inner, EditOptions, TickRange};
|
||||
use std::fs;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
|
@ -9,12 +9,30 @@ struct Args {
|
|||
path: String,
|
||||
#[arg(long)]
|
||||
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() {
|
||||
let args = Args::parse();
|
||||
let args: Args = Args::parse();
|
||||
let options = args.get_options();
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use crate::clean::clean_demo;
|
|||
use crate::cond::strip_cond;
|
||||
use crate::cut::cut;
|
||||
use crate::mutate::{MutatorList, PacketMutator};
|
||||
pub use crate::options::EditOptions;
|
||||
pub use crate::options::{EditOptions, TickRange, CondOptions};
|
||||
use crate::pov::unlock_pov;
|
||||
|
||||
extern crate web_sys;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue