• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tamada / gibo-wrapper / 10807769311

11 Sep 2024 08:18AM UTC coverage: 54.598%. First build
10807769311

push

github

tamada
add option for root subcommand

0 of 15 new or added lines in 2 files covered. (0.0%)

190 of 348 relevant lines covered (54.6%)

5.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/src/cli.rs
1
use clap::{Parser, Subcommand};
2
use std::fmt::{Display, Formatter, Result};
3

4
#[derive(Parser, Debug, PartialEq)]
5
#[command(
6
    version,
7
    author,
8
    about,
9
    arg_required_else_help = true,
10
    disable_version_flag = true,
11
    long_about = "gibo-wrapper acts like gibo and improves gibo by adding the following features.
12
    1. introduce current-list subcommand for dumping the boilerplates while keeping the prologue of .gitignore file.
13
    2. improve dump subcommand
14
       * append mode: appending the boilerplates into the .gitignore file.
15
       * remove mode: removing the boilerplates from the .gitignore file.
16
       * remove-duplication option removes the duplicated boilerplates names by dumping (-r option).
17
       * keep-prologue option keeps the prologue in the .gitignore (-k option).
18
    3. introduce the option for root subcommand
19
       * --open option of root subcommand opens the folder in the GUI file manager."
20
)]
21
pub struct CliOpts {
22
    #[clap(subcommand)]
23
    pub(crate) command: GiboCommand,
24

25
    #[clap(short, long, help = "Show verbose output")]
26
    pub(crate) verbose: bool,
×
27
}
28

29
#[derive(Debug, Subcommand, PartialEq)]
30
pub(crate) enum GiboCommand {
31
    #[command(about = "Dump a boilerplate")]
32
    Dump {
33
        #[clap(
34
            short,
35
            long,
36
            default_value_t = false,
1✔
37
            help = "Keep the prologue of the .gitignore"
38
        )]
39
        keep_prologue: bool,
×
40

41
        #[clap(
42
            short,
43
            long = "remove-duplication",
44
            default_value_t = false,
1✔
45
            help = "Remove the duplicated boilerplate names"
46
        )]
47
        remove_duplication: bool,
×
48

49
        #[clap(short, long = "in-place", help = "Update .gitignore files in-place")]
50
        in_place: bool,
×
51

52
        #[clap(short, long, help = "Show verbose output")]
53
        verbose: bool,
×
54

55
        #[clap(help = "the boilerplate names to dump.
56
Append boilerplates into the current .gitignore file if the name starts with `+`.
57
Remove boilerplates from the current .gitignore file if the name starts with `_`.")]
58
        args: Vec<String>,
1✔
59
    },
60
    #[command(about = "List available boilerplates")]
61
    List,
62
    #[command(about = "List the current boilerplates in the .gitignore file")]
63
    CurrentList,
64
    #[command(about = "Show the directory where gibo stores its boilerplates")]
65
    Root {
66
        #[clap(short = 'o', long = "open", help = "Open the folder in the GUI file manager")]
NEW
67
        open: bool,
×
68
    },
69
    #[command(about = "Search for boilerplates")]
70
    Search,
71
    #[command(about = "Update the gitignore boilerplate repository")]
72
    Update,
73
    #[command(about = "Show the current version number of gibo")]
74
    Version,
75
}
76

77
impl Display for GiboCommand {
78
    fn fmt(&self, f: &mut Formatter) -> Result {
×
79
        match self {
×
80
            GiboCommand::Dump { .. } => write!(f, "dump"),
×
81
            GiboCommand::List => write!(f, "list"),
×
82
            GiboCommand::CurrentList => write!(f, "current-list"),
×
NEW
83
            GiboCommand::Root { .. } => write!(f, "root"),
×
84
            GiboCommand::Search => write!(f, "search"),
×
85
            GiboCommand::Update => write!(f, "update"),
×
86
            GiboCommand::Version => write!(f, "version"),
×
87
        }
88
    }
×
89
}
90

91
#[cfg(test)]
92
mod tests {
93
    use super::*;
94

95
    #[test]
96
    fn test_gibo_command() {
1✔
97
        let cli1 = CliOpts::parse_from(&["gibo-wrapper", "dump", "+macos", "linux", "-k", "-r"]);
1✔
98
        assert_eq!(
1✔
99
            cli1.command,
1✔
100
            GiboCommand::Dump {
1✔
101
                keep_prologue: true,
1✔
102
                remove_duplication: true,
1✔
103
                in_place: false,
1✔
104
                verbose: false,
1✔
105
                args: vec!["+macos".to_string(), "linux".to_string()],
1✔
106
            }
1✔
107
        );
1✔
108
    }
1✔
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc