Browse Source

Make `add` accept list of files

This adds the possibility to add multiple files at once and fixes #4
master
Schneider 4 years ago
parent
commit
eeb9521ef9
Signed by: schneider GPG Key ID: 3F50B02A50039F3B
  1. 12
      src/app.rs

12
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<String>,
/// 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<String>, 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<structopt::clap::Shell>) -> 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)?,

Loading…
Cancel
Save