Refactoring (#31)

* Refactoring code

* Code formatting

* More changes

* Moved to icarus-models::user

* Some refactoring

* Updated icarus-models

* Removing constants

* Replaced with icarus-models constants

* Formatting

* Switched to constants from icarus-models:

* Replaced Token with AccessToken from icarus-models

* Updated icarus-models

* Formatting

* Removing code
This commit was merged in pull request #31.
This commit is contained in:
KD
2025-03-13 21:40:22 -04:00
committed by GitHub
parent a372bfcc05
commit c575d2e523
18 changed files with 105 additions and 169 deletions
+11 -5
View File
@@ -6,36 +6,42 @@ use crate::models::{self};
#[derive(Debug, Deserialize, Serialize)]
pub struct UserManager {
pub user: models::user::User,
pub user: icarus_models::user::User,
pub ica_action: models::icarus_action::IcarusAction,
}
impl Default for UserManager {
fn default() -> Self {
UserManager {
user: models::user::User::default(),
user: icarus_models::user::User::default(),
ica_action: models::icarus_action::IcarusAction::default(),
}
}
}
impl UserManager {
pub fn retrieve_user(&self) -> models::user::User {
pub fn retrieve_user(&self) -> icarus_models::user::User {
return self.user.clone();
}
pub fn parse_user_from_actions(&mut self) {
let args = &self.ica_action.flags;
// Quit the loop when two are found
let mut amt: i32 = 0;
for arg in args {
let flag = &arg.flag;
if flag == "-u" {
self.user.username = String::from(&arg.value);
amt += 1;
} else if flag == "-p" {
self.user.password = String::from(&arg.value);
amt += 1;
}
if flag == "-p" {
self.user.password = String::from(&arg.value);
if amt == 2 {
break;
}
}
}