| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -65,7 +65,10 @@ pub enum Command { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /// Add a line to the gitignore
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Add {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        /// The glob string that should be added
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        glob: String,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        glob:  String,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        /// Add the entry to the repo local ignore file
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        #[structopt(short)]
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        local: bool,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    },
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /// Download a gitignore for a language
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    Get {
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -87,7 +90,7 @@ pub enum Command { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/// Runs the command `add`
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					fn run_add(glob: &str) -> Result<()> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					fn run_add(glob: &str, local: bool) -> Result<()> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    trace!("running command `add` with glob '{}'", &glob);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let root = match git_dir()? {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Some(r) => r,
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -96,7 +99,11 @@ fn run_add(glob: &str) -> Result<()> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    info!("Working with git root in {:?}", root);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let mut file_path = PathBuf::from(&root);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    file_path.push(".gitignore");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if local {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        file_path.push(".git/info/exclude")
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } else {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        file_path.push(".gitignore");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let gitig = Gitignore::from_path(&file_path);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    gitig.add_line(glob)?;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    debug!("Added '{}' to {}", glob, gitig);
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -158,7 +165,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 } => run_add(&glob)?,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        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)?,
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |