Language Migration #21

Merged
kdeng00 merged 47 commits from rust-lg into master 2024-06-15 12:22:18 -04:00
8 changed files with 31 additions and 28 deletions
Showing only changes of commit ce0ec470ec - Show all commits
+8 -5
View File
@@ -1,5 +1,8 @@
mod managers;
mod models;
mod utilities;
mod parsers;
mod syncers;
use std::env;
use std::process;
@@ -75,12 +78,12 @@ fn main() {
chosen_act.print_action_and_flags();
let cmt_mgr = managers::commit_manager::CommitManager {
action: String::from(""),
flags: Vec::new(),
params: Vec::new(),
param_count: 1,
// action: String::from(""),
// flags: Vec::new(),
// params: Vec::new(),
// param_count: 1,
ica_action: chosen_act,
};
// cmt_mgr.commit_action();
cmt_mgr.commit_action();
}
+5 -7
View File
@@ -3,15 +3,14 @@ use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::models;
// mod managers {
use crate::utilities;
#[derive(Debug, Deserialize, Serialize)]
pub struct CommitManager {
pub action: String,
pub flags: Vec<models::flags::Flags>,
pub params: Vec<String>,
pub param_count: i32,
// pub action: String,
// pub flags: Vec<models::flags::Flags>,
// pub params: Vec<String>,
// pub param_count: i32,
pub ica_action: models::icarus_action::IcarusAction,
}
@@ -91,4 +90,3 @@ impl CommitManager {
return String::from("");
}
}
// }
+1 -1
View File
@@ -3,7 +3,7 @@ use std::default::Default;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct API {
pub url: String,
pub endpoint: String,
+1 -1
View File
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use crate::models;
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct IcarusAction {
pub action: String,
pub flags: Vec<models::flags::Flags>,
-3
View File
@@ -46,7 +46,6 @@ impl Song {
}
pub fn song_path(&self) -> String {
// let directory = &self.directory.unwrap();
let directory = &<std::option::Option<std::string::String> as Clone>::clone(&self.directory).unwrap();
let mut buffer: String = directory.to_string();
@@ -77,13 +76,11 @@ impl Song {
filename += ".wav";
}
// &mut self.filepath = Some(filename);
self.filepath = Some(filename);
return 0;
}
// TODO: Implement
pub fn to_metadata_json(&self) -> Result<String, serde_json::Error> {
return serde_json::to_string_pretty(&self);
}
+11 -6
View File
@@ -1,6 +1,7 @@
use crate::models;
#[derive(Clone, Debug)]
pub struct APIParser {
pub api: models::api::API,
pub ica_act: models::icarus_action::IcarusAction,
@@ -8,27 +9,31 @@ pub struct APIParser {
impl APIParser {
pub fn retrieve_api(&self) -> models::api::API {
return self.api;
return self.api.clone();
}
pub fn parse_api(&self) {
let flags = self.ica_act.flags;
pub fn parse_api(&mut self) {
let flags = self.ica_act.flags.clone();
println!("Parsing api");
for (i, elem) in flags {
let mut i = 0;
// for (i, elem) in flags {
for elem in flags {
let arg = elem.flag;
let value = elem.value;
if arg == "-h" {
if value.chars().nth((value.len() - 1)) == '/' {
if value.chars().nth((value.len() - 1)) == Some('/') {
self.api.url = value;
} else {
self.api.url = value + "/";
}
break;
}
i += 1;
}
self.api.version = "v1";
self.api.version = "v1".to_string();
}
}
+2 -2
View File
@@ -5,8 +5,8 @@ pub struct Checks {
}
impl Checks {
pub fn is_number(val: &String) -> bool {
return val.is_numeric();
pub fn is_numeric(text: &String) -> bool {
text.parse::<f64>().is_ok()
}
// TODO: Implement
+3 -3
View File
@@ -8,15 +8,15 @@ pub struct Conversions {
impl Conversions {
pub fn to_lower_char(val: &mut char) {
if val.is_alphabetic() {
val = val.to_lowercase();
*val = val.to_lowercase().next().unwrap();
}
}
pub fn initialize_values(&self) {
}
pub fn print_value<T>(&self, val: T) {
pub fn print_value<T: std::fmt::Debug>(&self, val: T) {
println!("Going to print value");
println!("{}", val);
println!("{:?}", val);
}
}