From eeb9521ef9f26df5f5fa6cd9900c58747ab9b242 Mon Sep 17 00:00:00 2001 From: Marcel Schneider Date: Tue, 25 May 2021 13:13:23 +0200 Subject: [PATCH] Make `add` accept list of files This adds the possibility to add multiple files at once and fixes #4 --- src/app.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index 481b538..703a4d2 100644 --- a/src/app.rs +++ b/src/app.rs @@ -65,7 +65,7 @@ pub enum Command { /// Add a line to the gitignore Add { /// The glob string that should be added - glob: String, + glob: Vec, /// Add the entry to the repo local ignore file #[structopt(short)] local: bool, @@ -90,7 +90,13 @@ pub enum Command { } /// Runs the command `add` -fn run_add(glob: &str, local: bool) -> Result<()> { +fn run_add(glob: Vec, local: bool) -> Result<()> { + for g in glob { + add(&g, local)?; + } + Ok(()) +} +fn add(glob: &str, local: bool) -> Result<()> { trace!("running command `add` with glob '{}'", &glob); let root = match git_dir()? { Some(r) => r, @@ -165,7 +171,7 @@ fn run_dump_completion(shell: Option) -> Result<()> { /// The actual `main()` pub fn main(opts: CliOpts) -> Result<()> { match opts.cmd { - Command::Add { glob, local } => run_add(&glob, local)?, + Command::Add { glob, local } => run_add(glob, local)?, Command::Get { lang, append } => run_get(&lang, append)?, Command::ListTemplates => run_list_templates()?, Command::DumpCompletions { shell } => run_dump_completion(shell)?,