chiral-cli-common 0.1.2

Common Types, Traits and Structs for Chiral Command-Line-Interface
Documentation
//! Dataset Commands
//! 
//! download from internet 
//! ```ds download -k dataset_kind```
//! 
//! load dataset
//! ```ds load -k - dataset_kind```
//! 
//! list all loaded datasets
//! ```ds ls```
//! 

use super::APPLET_TEMPLATE;

pub fn command() -> clap::Command {
    clap::Command::new("ds")
        .about("subcommand dataset")
        .subcommand(
            clap::Command::new("download")
                .about("download a dataset from internet.")
                .arg(
                    clap::Arg::new("kind")
                        .short('k')
                        .long("kind")
                        .required(true)
                )
        )
        .subcommand(
            clap::Command::new("load")
                .about("Load a dataset for computation.")
                .arg(
                    clap::Arg::new("kind")
                        .short('k')
                        .long("kind")
                        .required(true)
                )
        )
        .subcommand(
            clap::Command::new("ls")
                .about("List all the datasets.")
        )
        .subcommand(
            clap::Command::new("show")
                .about("Show an entry with ID")
                .arg(
                    clap::Arg::new("kind")
                        .short('k')
                        .long("kind")
                        .required(true)
                )
                .arg(
                    clap::Arg::new("id")
                        .short('i')
                        .long("id")
                        .required(true)
                )
        )
        .help_template(APPLET_TEMPLATE)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_command() {
        let cmd_1 = command();
        let res_1 = cmd_1.try_get_matches_from(vec!["ds", "download", "-k", "test_chembl"]);
        assert!(res_1.is_ok());
        let cmd_2 = command();
        let res_2 = cmd_2.try_get_matches_from(vec!["ds", "load", "-k", "test_chembl"]);
        assert!(res_2.is_ok());
        let cmd_3 = command();
        let res_3 = cmd_3.try_get_matches_from(vec!["ds", "ls"]);
        assert!(res_3.is_ok());
    }
}