From 7eae18a837e07b0223146762d85d5d7f3edd27dc Mon Sep 17 00:00:00 2001 From: Marcel Schneider Date: Fri, 28 Feb 2020 14:21:07 +0100 Subject: [PATCH] add cache read methods --- src/app.rs | 18 +++-------- src/helpers.rs | 15 ++++++++++ src/main.rs | 2 +- src/template.rs | 80 +++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 97 insertions(+), 18 deletions(-) diff --git a/src/app.rs b/src/app.rs index 6ea779c..7c1cda8 100644 --- a/src/app.rs +++ b/src/app.rs @@ -5,8 +5,6 @@ use std::path::PathBuf; // 3rd-party crate imports -use reqwest::blocking::Client; -use reqwest::header::{ACCEPT, CONTENT_TYPE, USER_AGENT}; use structopt::StructOpt; use log::{debug, error, info, trace, warn}; @@ -19,7 +17,6 @@ use crate::template::*; /// The verbosity level when no `-q` or `-v` arguments are given, with `0` being `-q` pub const DEFAULT_VERBOSITY: u64 = 1; -pub const DEFAULT_USER_AGENT: &str = "gitig"; /// Command-line argument schema /// @@ -99,18 +96,11 @@ fn run_get(lang: &str) -> Result<()> { } /// Runs the command `list-templates` +#[allow(clippy::print_stdout)] fn run_list_templates() -> Result<()> { - let client = Client::new(); - let 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")?; - let body: Vec