|
|
@ -69,6 +69,9 @@ pub enum Command { |
|
|
|
},
|
|
|
|
/// Download a gitignore for a language
|
|
|
|
Get {
|
|
|
|
/// Append template to an existing .gitignore file
|
|
|
|
#[structopt(short)]
|
|
|
|
append: bool,
|
|
|
|
/// The language for which the gitignore should be downloaded
|
|
|
|
///
|
|
|
|
/// A list with all available languages and projects can be printed with `list-templates`.
|
|
|
@ -77,7 +80,10 @@ pub enum Command { |
|
|
|
/// List all available templates that can be downloaded
|
|
|
|
ListTemplates,
|
|
|
|
/// 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`
|
|
|
@ -99,7 +105,7 @@ fn run_add(glob: &str) -> Result<()> { |
|
|
|
}
|
|
|
|
|
|
|
|
/// 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);
|
|
|
|
let mut root = match git_dir()? {
|
|
|
|
Some(r) => r,
|
|
|
@ -121,7 +127,7 @@ fn run_get(lang: &str) -> Result<()> { |
|
|
|
};
|
|
|
|
|
|
|
|
root.push(".gitignore");
|
|
|
|
tmpl.write_to(&root)?;
|
|
|
|
tmpl.write_to(&root, append)?;
|
|
|
|
trace!("Wrote template to file");
|
|
|
|
|
|
|
|
Ok(())
|
|
|
@ -153,7 +159,7 @@ fn run_dump_completion(shell: Option<structopt::clap::Shell>) -> Result<()> { |
|
|
|
pub fn main(opts: CliOpts) -> Result<()> {
|
|
|
|
match opts.cmd {
|
|
|
|
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::DumpCompletions { shell } => run_dump_completion(shell)?,
|
|
|
|
};
|
|
|
|