peprs-cli 0.1.0

Command-line tool for validating, inspecting, and converting PEP projects
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(clap::ValueEnum, Clone)]
pub enum ConvertFormat {
    /// YAML format
    Yaml,
    /// JSON format
    Json,
    /// CSV format
    Csv,
}

// #[derive(clap::ValueEnum, Clone)]
// pub enum WdlConvertFormat {
//     /// WDL (Workflow Description Language) format
//     Wdl,
// }

#[derive(Subcommand)]
pub enum Commands {
    /// Inspect project
    Inspect {
        /// Path to the project configuration yaml file.
        path: String,

        /// Optional name parameter
        #[arg(short = 'n', long = "sample-name")]
        name: Option<String>,

        /// Sample table index to use (default: "sample_name")
        #[arg(long = "st-index")]
        st_index: Option<String>,

        /// Subsample table index to use
        #[arg(long = "sst-index")]
        sst_index: Option<String>,

        /// Names of the amendments to activate
        #[arg(long = "amendments", num_args = 1..)]
        amendments: Option<Vec<String>>,
    },

    /// Validate a project against an eido schema
    Validate {
        /// Path to the project configuration yaml file.
        path: String,

        /// Path to the eido schema file (YAML or JSON).
        #[arg(short = 's', long = "schema")]
        schema: String,

        /// Name of the sample to validate. Only this sample will be validated.
        #[arg(short = 'n', long = "sample-name")]
        sample_name: Option<String>,

        /// Sample table index to use (default: "sample_name")
        #[arg(long = "st-index")]
        st_index: Option<String>,

        /// Subsample table index to use
        #[arg(long = "sst-index")]
        sst_index: Option<String>,

        /// Names of the amendments to activate
        #[arg(long = "amendments", num_args = 1..)]
        amendments: Option<Vec<String>>,
    },

    /// Convert PEP project to a different format (yaml, json, csv)
    Convert {
        /// Path to the project configuration yaml file.
        path: String,

        /// Output format: yaml, json, csv
        #[arg(value_enum, short = 'f', long = "format")]
        format: ConvertFormat,

        /// Output file path. If not provided, prints to stdout (only if < 100 samples).
        #[arg(short = 'p', long = "path")]
        output_path: Option<String>,

        /// Sample table index to use (default: "sample_name")
        #[arg(long = "st-index")]
        st_index: Option<String>,

        /// Subsample table index to use
        #[arg(long = "sst-index")]
        sst_index: Option<String>,

        /// Names of the amendments to activate
        #[arg(long = "amendments", num_args = 1..)]
        amendments: Option<Vec<String>>,
    },
    // /// Convert samples into WDL input format (deprecated)
    // ConvertWdl {
    //     path: String,
    //     schema: String,
    //     #[arg(value_enum, short = 'f', long = "to")]
    //     format: WdlConvertFormat,
    //     #[arg(short = 'n', long = "name")]
    //     name: Option<String>,
    //     #[arg(long = "nested-inputs")]
    //     nested_inputs: Option<bool>,
    //     #[arg(long = "show-non-literals")]
    //     show_non_literals: Option<bool>,
    //     #[arg(long = "hide-defaults")]
    //     hide_defaults: Option<bool>,
    // },
}