diff src/lib.rs @ 18:3f7b7a3ad8fe

Build three binaries instead of using arguments.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 26 Aug 2021 22:15:55 +0200
parents src/main.rs@0bce7fe96937
children
line wrap: on
line diff
copy from src/main.rs
copy to src/lib.rs
--- a/src/main.rs
+++ b/src/lib.rs
@@ -14,57 +14,12 @@
 // You should have received a copy of the GNU Affero General Public License
 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-#[cfg(feature = "gui")]
-mod gtk;
-#[cfg(feature = "gui")]
-mod client;
-mod server;
-mod state;
-mod uinput;
-
-pub use server::Event;
-
-use std::env::args;
-
-const MAX_X: i32 = 69920;
-const MAX_Y: i32 = 39980;
-
-const DEFAULT_WIDTH: i32 = 320;
-const DEFAULT_HEIGHT: i32 = 180;
-
-#[derive(Debug)]
-enum Ui {
-    Gtk,
-    Server,
-    Client,
-}
+pub mod protocol;
+pub mod state;
+pub mod uinput;
 
-fn main() {
-    let mut args: Vec<_> = args().collect();
-    let ui = match if args.len() > 1 {
-        args.remove(1)
-    } else {
-        String::from("client")
-    }
-    .as_str()
-    {
-        "gui" => Ui::Gtk,
-        "server" => Ui::Server,
-        "client" => Ui::Client,
-        name => {
-            eprintln!("Wrong UI “{}”, expected gui or server.", name);
-            std::process::exit(2);
-        }
-    };
+pub const MAX_X: i32 = 69920;
+pub const MAX_Y: i32 = 39980;
 
-    match ui {
-        #[cfg(feature = "gui")]
-        Ui::Gtk => gtk::main(&args),
-
-        #[cfg(not(feature = "gui"))]
-        Ui::Gtk => panic!("tablet-emu has been compiled without GUI support."),
-
-        Ui::Server => server::main(&args),
-        Ui::Client => client::main(&args),
-    }
-}
+pub const DEFAULT_WIDTH: i32 = 320;
+pub const DEFAULT_HEIGHT: i32 = 180;