use clap::{Parser, Subcommand, ValueEnum};

#[derive(Parser)]
#[command(name = "reskit")]
#[command(version = env!("CARGO_PKG_VERSION"))]
#[command(long_about = "reskit\nThe Retro Entertainment Software Toolkit - Utilities for authoring software for legacy video game systems\n(c) 2023 Ashley N. (ne0ndrag0n)")]
pub struct Args {

    #[command(subcommand)]
    pub tool: Tools

}

#[derive(Clone, Debug, ValueEnum)]
pub enum TileOrder {
    Tile,
    Sprite
}

#[derive(Clone, ValueEnum)]
pub enum TileOutputFormat {
    Bin,
    Inc
}

#[derive(Clone, ValueEnum)]
pub enum SequenceFormat {
    Dmf
}

#[derive(Clone, ValueEnum)]
pub enum DriverFormat {
    Esf
}

#[derive(Clone, ValueEnum)]
pub enum ArtifactListFormat {
    Asmx
}

#[derive(Clone, ValueEnum)]
pub enum SystemType {
    Md
}

#[derive(Subcommand)]
pub enum Tools {

    #[command(name = "tileset")]
    #[command(about = "Generate a set of tiles from an input image. Supports Sega Mega Drive VDP output format.")]
    Tileset {
        /// Input filename
        #[arg(short, long)]
        input_file: String,

        /// Output filename
        #[arg(short, long)]
        output_file: String,

        /// Output format
        #[arg(short, long, value_enum, default_value_t=TileOutputFormat::Bin)]
        format: TileOutputFormat,

        /// Tile order
        #[arg(short, long, value_enum, default_value_t=TileOrder::Tile)]
        tile_order: TileOrder
    },

    #[command(name = "soundtrack")]
    #[command(about = "Generate a soundtrack targeting a console sound driver, from one or more tracker sequence files.")]
    Soundtrack {
        /// Input filename(s)
        #[arg(short, long)]
        input_files: Vec<String>,

        /// Output directory
        #[arg(short, long, default_value_t=String::from("./"))]
        output_directory: String,

        /// Input sequence file format (the tracker used to compose the track)
        #[arg(long, value_enum, default_value_t=SequenceFormat::Dmf)]
        input_format: SequenceFormat,

        /// Output console file format (the sound driver your console uses)
        #[arg(long, value_enum, default_value_t=DriverFormat::Esf)]
        output_format: DriverFormat,

        /// Output format for the generated source file linking soundtracks and instruments
        #[arg(long, value_enum, default_value_t=ArtifactListFormat::Asmx)]
        source_file_format: ArtifactListFormat,

        /// Output directory for the source file
        #[arg(long, default_value_t=String::from("./"))]
        source_file_output_directory: String,

        /// Directory to output artifacts (instruments and samples)
        #[arg(long, default_value_t=String::from( "./" ))]
        artifact_output_directory: String
    },

    #[command(name = "level")]
    #[command(about = "Generate a level containing a tilemap and defining an entity-component system, from a selected Tiled Map Editor .tmx file.")]
    Level {
        /// Input filename
        #[arg(short, long)]
        input_file: String,

        /// Output directory for artifacts
        #[arg(short, long, default_value_t=String::from("./"))]
        output_directory: String,

        /// Console system type
        #[arg(short, long, value_enum, default_value_t=SystemType::Md)]
        console: SystemType
    }
}