add `bitsy-dedupe` executable

This commit is contained in:
Max Bradbury 2020-07-01 15:11:43 +01:00
parent 32addca850
commit 5b18892bb4
1 changed files with 16 additions and 0 deletions

16
src/bin/bitsy-dedupe.rs Normal file
View File

@ -0,0 +1,16 @@
extern crate bitsy_parser;
use bitsy_parser::game::Game;
use std::{env, fs};
const SYNTAX_ERROR: &str = "No game data specified. Usage: `bitsy-dedupe input.bitsy output.bitsy`";
fn main() {
let game = env::args().nth(1).expect(SYNTAX_ERROR);
let output = env::args().nth(2).expect(SYNTAX_ERROR);
let mut game = Game::from(fs::read_to_string(game).unwrap()).unwrap();
game.dedupe_tiles();
fs::write(output, game.to_string()).expect("Failed to write output file");
}