Added rust code
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "IcarusDownloadManager"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
|
serde_json = "1.0.115"
|
||||||
|
# rodio = "0.17.3"
|
||||||
|
# metadata = "0.1.8"
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
mod managers;
|
||||||
|
mod models;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::process;
|
||||||
|
|
||||||
|
// use managers::ActionManager;
|
||||||
|
// use models::{user, upload_form};
|
||||||
|
|
||||||
|
// use models::
|
||||||
|
|
||||||
|
|
||||||
|
fn exit_program(code: i32) {
|
||||||
|
process::exit(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_help() {
|
||||||
|
let msg: String = String::from(r#"icd [Action] [flag]
|
||||||
|
|
||||||
|
Actions
|
||||||
|
download
|
||||||
|
upload
|
||||||
|
upload-meta
|
||||||
|
retrieve
|
||||||
|
delete
|
||||||
|
|
||||||
|
Flags
|
||||||
|
Required for all actions
|
||||||
|
-u username
|
||||||
|
-p password
|
||||||
|
-h host
|
||||||
|
|
||||||
|
Required for upload
|
||||||
|
-s path of song
|
||||||
|
-sd directory where to search for songs to upload (Optional)
|
||||||
|
-sr directory where to recursively search for songs to upload (Optional)
|
||||||
|
-nc will not prompt the user when uploading from a directory
|
||||||
|
|
||||||
|
Required for upload with metadata
|
||||||
|
-s path of song
|
||||||
|
-t track number
|
||||||
|
-m metadata filepath
|
||||||
|
-ca coverart filepath
|
||||||
|
-scma directory where songs, metadata, and cover art exists and will be uploaded (Optional)
|
||||||
|
|
||||||
|
Required for download
|
||||||
|
-b song id
|
||||||
|
-d path to download song (Optional)
|
||||||
|
|
||||||
|
Required for retrieving records
|
||||||
|
-rt retrieve type (songs is only accepted)
|
||||||
|
|
||||||
|
Required for deleting a song
|
||||||
|
-D song id"#);
|
||||||
|
|
||||||
|
println!("{}", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
|
if args.len() == 0 {
|
||||||
|
print_help();
|
||||||
|
exit_program(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let act_mgr = managers::ActionManager {
|
||||||
|
action: String::from(""),
|
||||||
|
flags: Vec::new(),
|
||||||
|
params: args,
|
||||||
|
param_count: args.len(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let chosen_act = act_mgr.retrieve_icarus_action();
|
||||||
|
|
||||||
|
chosen_act.print_action_and_flags();
|
||||||
|
|
||||||
|
let cmt_mgr = managers::CommitManager {
|
||||||
|
};
|
||||||
|
|
||||||
|
cmt_mgr.commit_action();
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct ActionManager {
|
||||||
|
action: String,
|
||||||
|
flags: Vec<models::Flags>,
|
||||||
|
params: Vec<String>,
|
||||||
|
param_count: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActionManager {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn retrieve_icarus_action(&self) -> models::IcarusAction {
|
||||||
|
return models::IcarusAction {
|
||||||
|
action: String::from(""),
|
||||||
|
flags: Vec::new(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
fn supported_flags(&self) -> Vec<String> {
|
||||||
|
return Vec::new();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
fn supported_actions(&self) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn initialize(&self) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn validate_flags(&self) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn is_valid_flag(&self, flag: &String) -> bool{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn does_flag_have_value(&self, flag: &String) -> bool {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn print_action(&self) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn print_flags(&self) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn parsed_flags(&self) -> Vec<String> {
|
||||||
|
return Vec::new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct CommitManager {
|
||||||
|
action: String,
|
||||||
|
flags: Vec<models::Flags>,
|
||||||
|
params: Vec<String>,
|
||||||
|
param_count: i32,
|
||||||
|
ica_action: models::IcarusAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Album {
|
||||||
|
pub title: String,
|
||||||
|
pub album_artist: String,
|
||||||
|
pub genre: String,
|
||||||
|
pub year: i32,
|
||||||
|
pub track_count: i32,
|
||||||
|
pub disc_count: i32,
|
||||||
|
pub songs: Vec<models::Song>,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ActionValues {
|
||||||
|
DeleteAct,
|
||||||
|
DownloadAct,
|
||||||
|
RetrieveAct,
|
||||||
|
UploadAct,
|
||||||
|
UploadSongWithMetadata,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RetrieveTypes {
|
||||||
|
Songs
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Album {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn print_info(&self) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CommitManager {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn commit_action(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
fn map_actions(&self) -> HashMap<String, ActionValues> {
|
||||||
|
return HashMap::new();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
fn parse_token(&self, api: &models::API) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn upload_song_with_metadata(&self) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn sing_target_upload(&self, songpath: &String, track_id: &String,
|
||||||
|
meta_path: &String, cover_path: &String) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn multi_target_upload(&self, sourcepath: &String) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn initialize_disc_and_track(&self, song: &Song) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn parse_disc_and_track(&self, song: &Song, track_id: &String) {
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn check_for_no_confirm(&self) -> bool {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn retrieve_metadata(&self, path: &String) -> models::Album {
|
||||||
|
return Album {
|
||||||
|
title: String::from(""),
|
||||||
|
album_artist: String::from(""),
|
||||||
|
genre: String::from(""),
|
||||||
|
year: 0,
|
||||||
|
track_count: 0,
|
||||||
|
disc_count: 0,
|
||||||
|
songs: Vec::new(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// TODO: Implement
|
||||||
|
fn retrieve_file_content(&self, path: &String) -> String {
|
||||||
|
return String::from("");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct UserManager {
|
||||||
|
user: models::User,
|
||||||
|
ica_action: models::IcarusAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UserManager {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn retrieve_user(&self) -> models::User {
|
||||||
|
return models::User {
|
||||||
|
username: String::from(""),
|
||||||
|
password: String::from(""),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
fn parse_user_from_actions(&self) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct API {
|
||||||
|
pub url: String,
|
||||||
|
pub endpoint: String,
|
||||||
|
pub version: String,
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct Flags {
|
||||||
|
pub flag: String,
|
||||||
|
pub value: String,
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct IcarusAction {
|
||||||
|
pub action: String,
|
||||||
|
pub flags: Vec<models::Flags>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IcarusAction {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn retrieve_flag_value(&self, flag: &String) -> String {
|
||||||
|
return String::from("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn print_action_and_flags(&self) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct Song {
|
||||||
|
pub id: i32,
|
||||||
|
pub title: String,
|
||||||
|
pub artist: String,
|
||||||
|
pub album: String,
|
||||||
|
pub genre: String,
|
||||||
|
pub year: int,
|
||||||
|
pub duration: f64,
|
||||||
|
pub track: i32,
|
||||||
|
pub disc: i32,
|
||||||
|
pub data: String,
|
||||||
|
// use filepath instead
|
||||||
|
// pub song_path: String,
|
||||||
|
pub filepath: String,
|
||||||
|
pub directory: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Song {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn print_info(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn song_path(&self) -> String {
|
||||||
|
return String::from("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn generate_filename_from_track() -> i32 {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn to_metadata_json() -> String {
|
||||||
|
return String::from("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct CoverArt {
|
||||||
|
pub id: i32,
|
||||||
|
pub title: String,
|
||||||
|
pub path: String,
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct Token {
|
||||||
|
pub access_token: String,
|
||||||
|
pub token_type: String,
|
||||||
|
pub expiration: i32,
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct UploadForm {
|
||||||
|
pub url: String,
|
||||||
|
pub filepath: String,
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct User {
|
||||||
|
pub username: String,
|
||||||
|
pub password: String,
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct Checks {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Checks {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn is_number(val: &String) -> bool {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn item_in_container(container: &Vec<String>, item: &String,
|
||||||
|
func: fn(a: &String, b: &String) -> String) -> String {
|
||||||
|
return String::from("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn item_iter_in_container(container: &Vec<String>, item: &String,
|
||||||
|
func: fn(a: &String, b: &String) -> String) -> String {
|
||||||
|
return String::from("");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
struct Conversions {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Conversions {
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn to_lower_char(val: &mut String) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn initialize_values(&self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
pub fn print_value(&self, val: i32) {
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user