| 
					
					
						
							
						
					
					
				 | 
				@ -5,6 +5,8 @@ | 
			
		
		
	
		
			
				 | 
				 | 
				use std::path::PathBuf;
 | 
				 | 
				 | 
				use std::path::PathBuf;
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				// 3rd-party crate imports
 | 
				 | 
				 | 
				// 3rd-party crate imports
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				use reqwest::blocking::Client;
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				use reqwest::header::{ACCEPT, CONTENT_TYPE, USER_AGENT};
 | 
			
		
		
	
		
			
				 | 
				 | 
				use structopt::StructOpt;
 | 
				 | 
				 | 
				use structopt::StructOpt;
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				use log::{debug, error, info, trace, warn};
 | 
				 | 
				 | 
				use log::{debug, error, info, trace, warn};
 | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -16,6 +18,7 @@ use crate::helpers::{git_dir, BoilerplateOpts, HELP_TEMPLATE}; | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				/// The verbosity level when no `-q` or `-v` arguments are given, with `0` being `-q`
 | 
				 | 
				 | 
				/// The verbosity level when no `-q` or `-v` arguments are given, with `0` being `-q`
 | 
			
		
		
	
		
			
				 | 
				 | 
				pub const DEFAULT_VERBOSITY: u64 = 1;
 | 
				 | 
				 | 
				pub const DEFAULT_VERBOSITY: u64 = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				pub const DEFAULT_USER_AGENT: &str = "gitig";
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				/// Command-line argument schema
 | 
				 | 
				 | 
				/// Command-line argument schema
 | 
			
		
		
	
		
			
				 | 
				 | 
				///
 | 
				 | 
				 | 
				///
 | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
						
							
						
					
					
				 | 
				@ -68,6 +71,8 @@ pub enum Command { | 
			
		
		
	
		
			
				 | 
				 | 
				        /// The language for which the gitignore should be downloaded
 | 
				 | 
				 | 
				        /// The language for which the gitignore should be downloaded
 | 
			
		
		
	
		
			
				 | 
				 | 
				        lang: String,
 | 
				 | 
				 | 
				        lang: String,
 | 
			
		
		
	
		
			
				 | 
				 | 
				    },
 | 
				 | 
				 | 
				    },
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    /// List all available templates that can be downloaded
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    ListTemplates,
 | 
			
		
		
	
		
			
				 | 
				 | 
				}
 | 
				 | 
				 | 
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				/// Runs the command `add`
 | 
				 | 
				 | 
				/// Runs the command `add`
 | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -92,11 +97,28 @@ fn run_get(lang: &str) -> Result<()> { | 
			
		
		
	
		
			
				 | 
				 | 
				    unimplemented!();
 | 
				 | 
				 | 
				    unimplemented!();
 | 
			
		
		
	
		
			
				 | 
				 | 
				}
 | 
				 | 
				 | 
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				/// Runs the command `list-templates`
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				fn run_list_templates() -> Result<()> {
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    let client = Client::new();
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    let mut res = client
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .get("https://api.github.com/repos/github/gitignore/contents//")
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .header(ACCEPT, "application/jsonapplication/vnd.github.v3+json")
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .header(CONTENT_TYPE, "application/json")
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .header(USER_AGENT, format!("{} {}", DEFAULT_USER_AGENT, env!("CARGO_PKG_VERSION")))
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .send()
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .chain_err(|| "Error while sending request to query all templates")?;
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    println!("{:?}", &res);
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    let body = res.text().chain_err(|| "json")?;
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    println!("{:?}", &body);
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    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 {
 | 
			
		
		
	
		
			
				 | 
				 | 
				        Command::Add { glob } => run_add(&glob)?,
 | 
				 | 
				 | 
				        Command::Add { glob } => run_add(&glob)?,
 | 
			
		
		
	
		
			
				 | 
				 | 
				        Command::Get { lang } => run_get(&lang)?,
 | 
				 | 
				 | 
				        Command::Get { lang } => run_get(&lang)?,
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        Command::ListTemplates => run_list_templates()?,
 | 
			
		
		
	
		
			
				 | 
				 | 
				    };
 | 
				 | 
				 | 
				    };
 | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				    Ok(())
 | 
				 | 
				 | 
				    Ok(())
 | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  |