|
@ -65,7 +65,7 @@ pub enum Command { |
|
|
/// Add a line to the gitignore
|
|
|
/// Add a line to the gitignore
|
|
|
Add {
|
|
|
Add {
|
|
|
/// The glob string that should be added
|
|
|
/// The glob string that should be added
|
|
|
glob: Vec<String>,
|
|
|
|
|
|
|
|
|
glob: Vec<String>,
|
|
|
/// Add the entry to the repo local ignore file
|
|
|
/// Add the entry to the repo local ignore file
|
|
|
#[structopt(short)]
|
|
|
#[structopt(short)]
|
|
|
local: bool,
|
|
|
local: bool,
|
|
@ -78,7 +78,7 @@ pub enum Command { |
|
|
/// 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,
|
|
@ -87,6 +87,8 @@ pub enum Command { |
|
|
/// Shell to generate completion for
|
|
|
/// Shell to generate completion for
|
|
|
shell: Option<structopt::clap::Shell>,
|
|
|
shell: Option<structopt::clap::Shell>,
|
|
|
},
|
|
|
},
|
|
|
|
|
|
/// Print current .gitignore to stdout
|
|
|
|
|
|
Cat,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// Runs the command `add`
|
|
|
/// Runs the command `add`
|
|
@ -168,6 +170,15 @@ fn run_dump_completion(shell: Option<structopt::clap::Shell>) -> Result<()> { |
|
|
Ok(())
|
|
|
Ok(())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Runs the `cat` command to print the contents
|
|
|
|
|
|
fn run_cat() -> Result<()> {
|
|
|
|
|
|
let ignore_file = Gitignore::from_default_path()?;
|
|
|
|
|
|
let mut buf = String::new();
|
|
|
|
|
|
ignore_file.contents(&mut buf)?;
|
|
|
|
|
|
println!("{}", buf);
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/// The actual `main()`
|
|
|
/// The actual `main()`
|
|
|
pub fn main(opts: CliOpts) -> Result<()> {
|
|
|
pub fn main(opts: CliOpts) -> Result<()> {
|
|
|
match opts.cmd {
|
|
|
match opts.cmd {
|
|
@ -175,6 +186,7 @@ pub fn main(opts: CliOpts) -> Result<()> { |
|
|
Command::Get { lang, append } => run_get(&lang, append)?,
|
|
|
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)?,
|
|
|
|
|
|
Command::Cat => run_cat()?,
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
Ok(())
|
|
|