formatting stuff
This commit is contained in:
parent
ba11df89c8
commit
e753a7bf52
@ -1,6 +1,6 @@
|
|||||||
// gt - a gitea cli client
|
// gt - a gitea cli client
|
||||||
// Written by Wyatt J. Miller
|
// Written by Wyatt J. Miller
|
||||||
// All right reserved, 2020
|
// All right reserved, 2020 - 2021
|
||||||
// Licensed by the MPL v2
|
// Licensed by the MPL v2
|
||||||
|
|
||||||
mod arg;
|
mod arg;
|
||||||
@ -12,8 +12,8 @@ mod request;
|
|||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut matches: ArgMatches = arg::get_args();
|
let matches: ArgMatches = arg::get_args();
|
||||||
let mut config = crate::config::Configuration::new();
|
let config = crate::config::Configuration::new();
|
||||||
|
|
||||||
let auth = request::Authentication::new(&config);
|
let auth = request::Authentication::new(&config);
|
||||||
let request = auth.request_chooser(config.clone(), matches);
|
let request = auth.request_chooser(config.clone(), matches);
|
||||||
|
@ -57,20 +57,17 @@ impl Authentication{
|
|||||||
/// secure methods. Currently, only two methods are supported: API token, and
|
/// secure methods. Currently, only two methods are supported: API token, and
|
||||||
/// username/password combo.
|
/// username/password combo.
|
||||||
pub fn new(config: &Configuration) -> Authentication {
|
pub fn new(config: &Configuration) -> Authentication {
|
||||||
let basic_auth: String;
|
|
||||||
let api_auth: String;
|
|
||||||
|
|
||||||
// TODO: might be broken, haven't tested
|
// TODO: might be broken, haven't tested
|
||||||
// this is horror code, I know it
|
// this is horror code, I know it
|
||||||
// match the damn thing
|
// match the damn thing
|
||||||
// someone is going to take this and put it in r/badcode lol
|
// someone is going to take this and put it in r/badcode lol
|
||||||
basic_auth = config
|
let basic_auth = config
|
||||||
.password
|
.password
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
api_auth = config
|
let api_auth = config
|
||||||
.api_token
|
.api_token
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -78,7 +75,12 @@ impl Authentication{
|
|||||||
|
|
||||||
if api_auth.is_empty() {
|
if api_auth.is_empty() {
|
||||||
if !(basic_auth.is_empty()) {
|
if !(basic_auth.is_empty()) {
|
||||||
Authentication::with_basic(config.username.as_ref().unwrap().to_string(), basic_auth)
|
Authentication::with_basic(config
|
||||||
|
.username
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.to_string(),
|
||||||
|
basic_auth)
|
||||||
} else {
|
} else {
|
||||||
panic!("Must have some form of authentication! Exiting...");
|
panic!("Must have some form of authentication! Exiting...");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user