Skip to content

Commit

Permalink
v2.0.2 (#20)
Browse files Browse the repository at this point in the history
- [feat: ✨ add api_omg_lol as enviroment
var](ea12cd5)
  • Loading branch information
M1n-74316D65 authored May 28, 2024
2 parents 7b841c5 + 2f3a8bf commit 09c9db9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 20 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)) => {
Expand Down

0 comments on commit 09c9db9

Please sign in to comment.