27 lines
878 B
Rust
27 lines
878 B
Rust
extern crate bitsy_parser;
|
|
use bitsy_parser::game::Game;
|
|
use std::{env, fs};
|
|
|
|
fn main() {
|
|
let game_a = env::args()
|
|
.nth(1)
|
|
.expect("No main game specified. Usage: `bitsy-merge main.bitsy additional.bitsy output.bitsy`");
|
|
|
|
// todo allow numerous additional games
|
|
let game_b = env::args()
|
|
.nth(2)
|
|
.expect("No additional game specified. Usage: `bitsy-merge main.bitsy additional.bitsy output.bitsy`");
|
|
|
|
let outfile = env::args()
|
|
.nth(3)
|
|
.expect("No output file specified. Usage: `bitsy-merge main.bitsy additional.bitsy output.bitsy`");
|
|
|
|
let mut game_a = Game::from(fs::read_to_string(game_a).unwrap()).unwrap();
|
|
let game_b = Game::from(fs::read_to_string(game_b).unwrap()).unwrap();
|
|
|
|
game_a.merge(game_b);
|
|
|
|
fs::write(outfile, game_a.to_string())
|
|
.expect("Failed to write output file");
|
|
}
|