// -*- coding: utf-8 -*- // // Copyright 2021 Michael Büsch // // Licensed under the Apache License version 2.0 // or the MIT license, at your option. // SPDX-License-Identifier: Apache-2.0 OR MIT // mod gtk_helpers; mod joystick; mod main_window; mod print; use crate::main_window::MainWindow; use crate::print::Print; use anyhow as ah; use expect_exit::ExpectedWithError; use gtk_helpers::*; use structopt::StructOpt; #[derive(StructOpt, Debug)] #[structopt(name = "gamers")] struct Opts { /// Set the log level. /// 0 = Silent. Don't print anything. /// 1 = Only print errors. /// 2 = Print errors and warnings. /// 3 = Print errors, warnings and info. /// 4 = Print errors, warnings, info and debug #[structopt(short = "L", long, default_value = "3")] log_level: u8, #[structopt(short, long)] edit: bool, /// Map name to load. #[structopt(name = "MAP")] map: Option, } fn app_fn(app: >k::Application) { let opt = Opts::from_args(); let map = match opt.map { Some(map) => map, _ => "001".to_string(), }; if opt.edit { //TODO } else { MainWindow::new(app, &map) .expect_or_exit_perror_("Startup failed") .borrow() .main_window() .show(); } } fn main() -> ah::Result<()> { let opt = Opts::from_args(); Print::set_level_number(opt.log_level); let app = gtk::Application::new(None, gio::ApplicationFlags::FLAGS_NONE); app.connect_activate(app_fn); let args: Vec<&str> = vec![]; app.run_with_args(&args); Ok(()) } // vim: ts=4 sw=4 expandtab