acutally read the options from structopt

This commit is contained in:
Michael Zhang 2021-01-09 12:17:51 -06:00
parent cd96305f57
commit f622c3cfee
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B

View file

@ -2,8 +2,6 @@
extern crate anyhow; extern crate anyhow;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
#[macro_use]
extern crate structopt;
extern crate bass_sys as bass; extern crate bass_sys as bass;
mod audio; mod audio;
@ -12,7 +10,6 @@ mod game;
mod hit_object; mod hit_object;
mod skin; mod skin;
use std::env;
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::Result; use anyhow::Result;
@ -20,6 +17,7 @@ use ggez::{
conf::{WindowMode, WindowSetup}, conf::{WindowMode, WindowSetup},
event, ContextBuilder, event, ContextBuilder,
}; };
use structopt::StructOpt;
use crate::game::Game; use crate::game::Game;
@ -33,10 +31,11 @@ struct Opt {
} }
fn main() -> Result<()> { fn main() -> Result<()> {
let opt = Opt::from_args();
stderrlog::new() stderrlog::new()
.module("editor") .module("editor")
.module("bass_sys") .module("bass_sys")
.verbosity(2) .verbosity(opt.verbose)
.init() .init()
.unwrap(); .unwrap();
@ -48,8 +47,11 @@ fn main() -> Result<()> {
let (mut ctx, mut event_loop) = cb.build()?; let (mut ctx, mut event_loop) = cb.build()?;
let mut game = Game::new()?; let mut game = Game::new()?;
game.skin.load_all(&mut ctx)?; game.skin.load_all(&mut ctx)?;
let path = env::args().nth(1).unwrap();
game.load_beatmap(path)?; if let Some(path) = opt.path {
game.load_beatmap(path)?;
}
event::run(&mut ctx, &mut event_loop, &mut game)?; event::run(&mut ctx, &mut event_loop, &mut game)?;
Ok(()) Ok(())