tidyup
This commit is contained in:
parent
5b18892bb4
commit
b82b1fb145
|
@ -2,25 +2,19 @@ extern crate bitsy_parser;
|
|||
use bitsy_parser::game::Game;
|
||||
use std::{env, fs};
|
||||
|
||||
const SYNTAX_ERROR: &str = "No main game specified. Usage: `bitsy-merge main.bitsy additional.bitsy output.bitsy`";
|
||||
|
||||
fn main() {
|
||||
let game_a = env::args()
|
||||
.nth(1)
|
||||
.expect("No main game specified. Usage: `bitsy-merge main.bitsy additional.bitsy output.bitsy`");
|
||||
|
||||
let game_a = env::args().nth(1).expect(SYNTAX_ERROR);
|
||||
let game_b = env::args().nth(2).expect(SYNTAX_ERROR);
|
||||
let output = env::args().nth(3).expect(SYNTAX_ERROR);
|
||||
// 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())
|
||||
fs::write(output, game_a.to_string())
|
||||
.expect("Failed to write output file");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue