diff --git a/Cargo.toml b/Cargo.toml index 52c0baf..fab5a24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,5 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +image = "^0.23" +colour = "^0.5" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7a11a9..1074e7f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,62 @@ -fn main() { - println!("Hello, world!"); +extern crate image; +#[macro_use] +extern crate colour; + +use std::env::{ Args, args }; +use std::process::exit; + +mod reskit; +use reskit::tileset; + +struct ArgumentOption { + pub key: String, + pub value: String +} + +fn print_help() { + println!( "Usage:" ); + println!( "reskit [plugin] options" ); + println!( "" ); + println!( "Available Plugins:" ); + println!( " tileset - Convert 15-colour PNG to Sega Genesis VDP format" ); + println!( " Output as .bin containing palette, then tiles"); + println!( "" ); + println!( "Options:" ); + println!( "--input Specify input file for plugin" ); + println!( "--output Specify output file/path for plugin" ); +} + +fn get_option( arguments: &mut Args ) -> Option< ArgumentOption > { + Some( ArgumentOption{ key: arguments.next()?, value: arguments.next()? } ) +} + +fn load_module( module: String, arguments: Args ) -> i32 { + // Discriminate module + match module.as_str() { + "reskit" => { + 42 + }, + _ => { + red!( "fatal: " ); println!( "invalid module: {}", module ); + 2 + } + } +} + +fn main() { + cyan!( "reskit" ); println!( " - Sega Genesis Resource Kit (v0.0.1a)" ); + println!( "(c) 2021 Ashley N. (ne0ndrag0n)" ); + + let mut args = args(); + args.next(); // Burn arg1 + + let mode = match args.next() { + Some( mode ) => mode, + None => { + print_help(); + exit( 1 ); + } + }; + + exit( load_module( mode, args ) ); } diff --git a/src/reskit/mod.rs b/src/reskit/mod.rs new file mode 100644 index 0000000..ca8ca15 --- /dev/null +++ b/src/reskit/mod.rs @@ -0,0 +1 @@ +pub mod tileset; \ No newline at end of file diff --git a/src/reskit/tileset.rs b/src/reskit/tileset.rs new file mode 100644 index 0000000..eec8c0a --- /dev/null +++ b/src/reskit/tileset.rs @@ -0,0 +1,3 @@ +pub fn load_tileset() -> i32 { + 3 +} \ No newline at end of file