Skip to content
1        10        20        30        40        50        60        701use clap::{Parser, Subcommand};23#[derive(Parser)]4#[command(name = "pike", about = "Create GitHub issues from the CLI", version)]5pub struct Cli {6    #[command(subcommand)]7    pub command: Option<Commands>,8}910#[derive(Subcommand)]11pub enum Commands {12    /// Configure pike and pre-fetch repository/project data13    Setup,14}1516#[cfg(test)]17mod tests {18    use super::*;19    use clap::Parser;2021    #[test]22    fn parse_no_subcommand() {23        let cli = Cli::try_parse_from(vec!["pike"]);24        assert!(cli.is_ok());25        assert!(cli.unwrap().command.is_none());26    }2728    #[test]29    fn parse_setup() {30        let cli = Cli::try_parse_from(vec!["pike", "setup"]);31        assert!(cli.is_ok());32        assert!(matches!(cli.unwrap().command, Some(Commands::Setup)));33    }3435    #[test]36    fn parse_version() {37        let result = Cli::try_parse_from(vec!["pike", "--version"]);38        assert!(result.is_err());39    }40}