From b75b7050752f5d94f66306244925e4b7c544e68a Mon Sep 17 00:00:00 2001 From: M1n <54779580+M1n-74316D65@users.noreply.github.com> Date: Tue, 28 May 2024 04:25:44 +0200 Subject: [PATCH 1/3] build: :bookmark: from 2.0.1 to 2.0.2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3420934..7d7fbeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pastol" -version = "2.0.1" +version = "2.0.2" authors = ["M1n-74316D65"] edition = "2021" description = "Paste.lol on the command line." From ea12cd5588a401deb9a17b242c92ac578fb49f6d Mon Sep 17 00:00:00 2001 From: M1n <54779580+M1n-74316D65@users.noreply.github.com> Date: Tue, 28 May 2024 04:29:18 +0200 Subject: [PATCH 2/3] feat: :sparkles: add api_omg_lol as enviroment var --- src/main.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 372774a..6b70515 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use clap::error::{Error, ErrorKind}; use clap::{ArgMatches, Args as _, Command, FromArgMatches, Parser, Subcommand}; +use std::env; mod config_manager; mod deserializer; @@ -190,23 +191,41 @@ fn main() { let args = Cli::parse(); let result = deserializer::deserialized(); match result { - Ok(config) => match &args.subcommand { + Ok(mut config) => match &args.subcommand { Some(CliSub::Add(args)) => { + if let Some(val) = env::var("api_omg_lol").ok() { + config.api_key = val; + } petition_manager::add(args, config); } Some(CliSub::Search(args)) => { + if let Some(val) = env::var("api_omg_lol").ok() { + config.api_key = val; + } petition_manager::search(args, config); } Some(CliSub::Download(args)) => { + if let Some(val) = env::var("api_omg_lol").ok() { + config.api_key = val; + } petition_manager::download(args, config); } Some(CliSub::View(args)) => { + if let Some(val) = env::var("api_omg_lol").ok() { + config.api_key = val; + } petition_manager::view(args, config); } Some(CliSub::Remove(args)) => { + if let Some(val) = env::var("api_omg_lol").ok() { + config.api_key = val; + } petition_manager::remove(args, config); } Some(CliSub::List(_)) => { + if let Some(val) = env::var("api_omg_lol").ok() { + config.api_key = val; + } petition_manager::list(config); } Some(CliSub::Settings(args)) => { From 2f3a8bf260837dc3881d728c005c5d49c9991abc Mon Sep 17 00:00:00 2001 From: M1n <54779580+M1n-74316D65@users.noreply.github.com> Date: Tue, 28 May 2024 04:33:59 +0200 Subject: [PATCH 3/3] docs: :memo: add env var setup doc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index dce693e..60cd868 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,8 @@ help Print this message or the help of the given subcommand(s) 1. Set user and API key. ```sh pastol --setuser your_username --setapikey your_api_key + + # if the env var api_omg_lol is set it will be used instead ``` 2. Exampe as adam.