monorepo/coordinates/src/bin/default_map.rs

33 lines
653 B
Rust
Raw Normal View History

use coordinates::hex_map;
use std::path::PathBuf;
#[derive(Clone)]
struct MapVal;
impl Default for MapVal {
fn default() -> Self {
Self
}
}
impl From<MapVal> for String {
fn from(_val: MapVal) -> Self {
".".to_owned()
}
}
fn main() {
let mut args = std::env::args().skip(1);
let filename = args
.next()
.map(|p| PathBuf::from(p))
.expect("A filename is required");
let size = args
.next()
.and_then(|s| s.parse::<usize>().ok())
.unwrap_or(3);
let map: hex_map::Map<MapVal> = hex_map::Map::new_hexagonal(size);
hex_map::write_file(filename, map);
}