|
@ -69,15 +69,21 @@ pub enum Command { |
|
|
},
|
|
|
},
|
|
|
/// Download a gitignore for a language
|
|
|
/// Download a gitignore for a language
|
|
|
Get {
|
|
|
Get {
|
|
|
|
|
|
/// Append template to an existing .gitignore file
|
|
|
|
|
|
#[structopt(short)]
|
|
|
|
|
|
append: bool,
|
|
|
/// The language for which the gitignore should be downloaded
|
|
|
/// The language for which the gitignore should be downloaded
|
|
|
///
|
|
|
///
|
|
|
/// A list with all available languages and projects can be printed with `list-templates`.
|
|
|
/// A list with all available languages and projects can be printed with `list-templates`.
|
|
|
lang: String,
|
|
|
|
|
|
|
|
|
lang: String,
|
|
|
},
|
|
|
},
|
|
|
/// List all available templates that can be downloaded
|
|
|
/// List all available templates that can be downloaded
|
|
|
ListTemplates,
|
|
|
ListTemplates,
|
|
|
/// Write a completion definition for the specified shell to stdout (bash, zsh, etc.)
|
|
|
/// Write a completion definition for the specified shell to stdout (bash, zsh, etc.)
|
|
|
DumpCompletions { shell: Option<structopt::clap::Shell> },
|
|
|
|
|
|
|
|
|
DumpCompletions {
|
|
|
|
|
|
/// Shell to generate completion for
|
|
|
|
|
|
shell: Option<structopt::clap::Shell>,
|
|
|
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// Runs the command `add`
|
|
|
/// Runs the command `add`
|
|
@ -99,7 +105,7 @@ fn run_add(glob: &str) -> Result<()> { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// Runs the command `get`
|
|
|
/// Runs the command `get`
|
|
|
fn run_get(lang: &str) -> Result<()> {
|
|
|
|
|
|
|
|
|
fn run_get(lang: &str, append: bool) -> Result<()> {
|
|
|
trace!("Run command `get` with lang {}", &lang);
|
|
|
trace!("Run command `get` with lang {}", &lang);
|
|
|
let mut root = match git_dir()? {
|
|
|
let mut root = match git_dir()? {
|
|
|
Some(r) => r,
|
|
|
Some(r) => r,
|
|
@ -121,7 +127,7 @@ fn run_get(lang: &str) -> Result<()> { |
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
root.push(".gitignore");
|
|
|
root.push(".gitignore");
|
|
|
tmpl.write_to(&root)?;
|
|
|
|
|
|
|
|
|
tmpl.write_to(&root, append)?;
|
|
|
trace!("Wrote template to file");
|
|
|
trace!("Wrote template to file");
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
Ok(())
|
|
@ -153,7 +159,7 @@ fn run_dump_completion(shell: Option<structopt::clap::Shell>) -> Result<()> { |
|
|
pub fn main(opts: CliOpts) -> Result<()> {
|
|
|
pub fn main(opts: CliOpts) -> Result<()> {
|
|
|
match opts.cmd {
|
|
|
match opts.cmd {
|
|
|
Command::Add { glob } => run_add(&glob)?,
|
|
|
Command::Add { glob } => run_add(&glob)?,
|
|
|
Command::Get { lang } => run_get(&lang)?,
|
|
|
|
|
|
|
|
|
Command::Get { lang, append } => run_get(&lang, append)?,
|
|
|
Command::ListTemplates => run_list_templates()?,
|
|
|
Command::ListTemplates => run_list_templates()?,
|
|
|
Command::DumpCompletions { shell } => run_dump_completion(shell)?,
|
|
|
Command::DumpCompletions { shell } => run_dump_completion(shell)?,
|
|
|
};
|
|
|
};
|
|
|