better docs
This commit is contained in:
		
							parent
							
								
									46e0eb210d
								
							
						
					
					
						commit
						cc8f3c919d
					
				
					 3 changed files with 138 additions and 92 deletions
				
			
		
							
								
								
									
										95
									
								
								README.org
									
										
									
									
									
								
							
							
						
						
									
										95
									
								
								README.org
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -111,41 +111,8 @@ fn main() {
 | 
			
		|||
 | 
			
		||||
*** Functions
 | 
			
		||||
**** Main commands
 | 
			
		||||
***** Sync
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn set_member(config_path: String, member: String) -> Result<(), &'static str> {
 | 
			
		||||
    let config = get_config(&config_path);
 | 
			
		||||
    if config == Value::Null {
 | 
			
		||||
        return Err("Config not found. Stopping");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let system: System = get_system(&config_path);
 | 
			
		||||
 | 
			
		||||
    let mut flag = false;
 | 
			
		||||
    for mem in &system.members {
 | 
			
		||||
        if mem.name.to_lowercase() == member.to_lowercase() {
 | 
			
		||||
            flag = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if flag {
 | 
			
		||||
        println!("Member {member} found");
 | 
			
		||||
        get_fronters(&config["pk_key"].as_str().unwrap(), &system.pk_userid, &config["sp_key"].as_str().unwrap(), &system);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        Ok(())
 | 
			
		||||
    } else {
 | 
			
		||||
        Err("Member {member} not found")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
fn set_empty(config_path: String) {
 | 
			
		||||
    let config = load_json(format!("{}/config.json", config_path));
 | 
			
		||||
    let system = get_system(&config_path);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
fn sync(config_path: String) -> Result<(), String>{
 | 
			
		||||
    // Get config
 | 
			
		||||
    let config = get_config(&config_path);
 | 
			
		||||
| 
						 | 
				
			
			@ -202,7 +169,46 @@ fn sync(config_path: String) -> Result<(), String>{
 | 
			
		|||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
***** Set member
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
TODO fn set_empty(config_path: String) {
 | 
			
		||||
TODO     let config = load_json(format!("{}/config.json", config_path));
 | 
			
		||||
TODO     let system = get_system(&config_path);
 | 
			
		||||
TODO }
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
fn set_member(config_path: String, member: String) -> Result<(), &'static str> {
 | 
			
		||||
    let config = get_config(&config_path);
 | 
			
		||||
    if config == Value::Null {
 | 
			
		||||
        return Err("Config not found. Stopping");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let system: System = get_system(&config_path);
 | 
			
		||||
 | 
			
		||||
    let mut flag = false;
 | 
			
		||||
    for mem in &system.members {
 | 
			
		||||
        if mem.name.to_lowercase() == member.to_lowercase() {
 | 
			
		||||
            flag = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if flag {
 | 
			
		||||
        println!("Member {member} found");
 | 
			
		||||
        get_fronters(&config["pk_key"].as_str().unwrap(), &system.pk_userid, &config["sp_key"].as_str().unwrap(), &system);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        Ok(())
 | 
			
		||||
    } else {
 | 
			
		||||
        Err("Member {member} not found")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
**** Pluralkit
 | 
			
		||||
***** Get system
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn pk_get_system(key: &str) -> Value {
 | 
			
		||||
    let url = format!("{}/systems/@me", PK_URL);
 | 
			
		||||
| 
						 | 
				
			
			@ -219,12 +225,16 @@ fn pk_get_members(key: &str, sysid: &str) -> Vec<Value> {
 | 
			
		|||
 | 
			
		||||
    return datas;
 | 
			
		||||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
***** Get fronters
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn pk_get_fronters(key: &str, sysid: &str) -> Vec<String> {
 | 
			
		||||
    let url = format!("{}/systems/{}/fronters", PK_URL, sysid);
 | 
			
		||||
 | 
			
		||||
    let res = http_get_request(url,key);
 | 
			
		||||
    let data: Value = serde_json::from_str(&res.unwrap()).unwrap();
 | 
			
		||||
    println!("{:?}", data);
 | 
			
		||||
    let memberdata = &data["members"].as_array();
 | 
			
		||||
 | 
			
		||||
    let mut members: Vec<String> = Vec::new();
 | 
			
		||||
| 
						 | 
				
			
			@ -240,6 +250,7 @@ fn pk_get_fronters(key: &str, sysid: &str) -> Vec<String> {
 | 
			
		|||
#+end_src
 | 
			
		||||
 | 
			
		||||
**** Simplyplural
 | 
			
		||||
***** Get user ID
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn sp_get_userid(key: &str) -> String {
 | 
			
		||||
    let url = format!("{}/me", SP_URL);
 | 
			
		||||
| 
						 | 
				
			
			@ -248,7 +259,10 @@ fn sp_get_userid(key: &str) -> String {
 | 
			
		|||
    let json_res : Value = serde_json::from_str(&res.unwrap()).unwrap();
 | 
			
		||||
    return json_res["id"].as_str().unwrap().to_string();
 | 
			
		||||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
***** Get members ID
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn sp_get_memberids(key: &str, system_id: &str) -> HashMap<String, String> {
 | 
			
		||||
    let url = format!("{}/members/{}", SP_URL, system_id);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -262,7 +276,10 @@ fn sp_get_memberids(key: &str, system_id: &str) -> HashMap<String, String> {
 | 
			
		|||
 | 
			
		||||
    return sp_memberdata;
 | 
			
		||||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
***** Get ID from member
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn get_sp_id(mem: &Member, ids: &HashMap<String, String>) -> String {
 | 
			
		||||
 | 
			
		||||
    let mut member_id = String::new();
 | 
			
		||||
| 
						 | 
				
			
			@ -275,7 +292,10 @@ fn get_sp_id(mem: &Member, ids: &HashMap<String, String>) -> String {
 | 
			
		|||
 | 
			
		||||
    return member_id;
 | 
			
		||||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
***** Get fronters
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn sp_get_fronters(key: &str, sys: &System) -> Vec<String> {
 | 
			
		||||
    let url = format!("{}/fronters", SP_URL);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -299,6 +319,7 @@ fn sp_get_fronters(key: &str, sys: &System) -> Vec<String> {
 | 
			
		|||
#+end_src
 | 
			
		||||
 | 
			
		||||
**** Utilities
 | 
			
		||||
***** Load JSON
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn load_json(path: String) -> Value {
 | 
			
		||||
    if Path::new(&path).exists() {
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +330,10 @@ fn load_json(path: String) -> Value {
 | 
			
		|||
        return Value::Null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
***** Get config json
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn get_config(config_path: &str) -> Value {
 | 
			
		||||
    let path = format!("{}/config.json", config_path);
 | 
			
		||||
    if Path::new(config_path).exists() {
 | 
			
		||||
| 
						 | 
				
			
			@ -339,7 +363,10 @@ fn get_config(config_path: &str) -> Value {
 | 
			
		|||
        return Value::Null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
#+end_src
 | 
			
		||||
 | 
			
		||||
***** Get system json
 | 
			
		||||
#+begin_src rust :tangle src/main.rs :comments link
 | 
			
		||||
fn get_system(config_path: &str) -> System {
 | 
			
		||||
    let path = format!("{}/system.json", config_path);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										26
									
								
								TODO.org
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								TODO.org
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -8,33 +8,37 @@
 | 
			
		|||
:PROPERTIES:
 | 
			
		||||
:COOKIE_DATA: recursive
 | 
			
		||||
:END:
 | 
			
		||||
*** Milestone 1.0 [3/11][27%]
 | 
			
		||||
*** Milestone 1.0 [4/16][25%]
 | 
			
		||||
**** Main functions [1/9][11%]
 | 
			
		||||
***** Finished Add `sync` command
 | 
			
		||||
***** InProgress Add `set` command [0/2]
 | 
			
		||||
****** HighPriority [SET] Add empty
 | 
			
		||||
****** InProgress [SET] Add set
 | 
			
		||||
***** HighPriority Add `get` command
 | 
			
		||||
***** LowPriority Add `get` command
 | 
			
		||||
***** LowPriority Add `Add` command [0/2]
 | 
			
		||||
****** LowPriority [ADD] Add empty
 | 
			
		||||
****** LowPriority [ADD] Add set
 | 
			
		||||
***** LowPriority Add `setgroup` command
 | 
			
		||||
**** Utils [2/2][100%]
 | 
			
		||||
**** Utils [3/7][42%]
 | 
			
		||||
***** Json loading [2/2]
 | 
			
		||||
****** Finished Add new function to get the config create empty in path if not exists
 | 
			
		||||
****** Finished `Get system` if Value::Null sync and load json
 | 
			
		||||
***** InProgress Get current front
 | 
			
		||||
***** Finished Get current front
 | 
			
		||||
***** InProgress Compare if sent members are currently fronting and keep them otherwise add to fronting array
 | 
			
		||||
***** HighPriority Check for mismatch in fronting between pluralkit and simplyplural
 | 
			
		||||
***** LowPriority Get fronters handles the front file
 | 
			
		||||
***** LowPriority Rofi stuff
 | 
			
		||||
 | 
			
		||||
** Kanban
 | 
			
		||||
| Backlog | LowPriority                    | HighPriority                   | InProgress                     | Finished                       |
 | 
			
		||||
|---------+-------------------------+-------------------+-------------------------+--------------------------------|
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::Add `Add` command \[0/2\]][Add `Add` command {0/2}]] | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add empty][{SET} Add empty]]   | [[/home/alicia/git/pluralshit/TODO.org::Add `set` command \[0/2\]][Add `set` command {0/2}]] | [[/home/alicia/git/pluralshit/TODO.org::Add `sync` command][Add `sync` command]]             |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add empty][{ADD} Add empty]]         | [[/home/alicia/git/pluralshit/TODO.org::Add `get` command][Add `get` command]] | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add set][{SET} Add set]]           | [[/home/alicia/git/pluralshit/TODO.org::Add new function to get the config create empty in path if not exists][Add new function to get the co]] |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add set][{ADD} Add set]]           |                   |                         | [[/home/alicia/git/pluralshit/TODO.org::`Get system` if Value::Null sync and load json][`Get system` if Value::Null sy]] |
 | 
			
		||||
|---------+--------------------------------+--------------------------------+--------------------------------+--------------------------------|
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::Add `get` command][Add `get` command]]              | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add empty][{SET} Add empty]]                | [[/home/alicia/git/pluralshit/TODO.org::Add `set` command \[0/2\]][Add `set` command {0/2}]]        | [[/home/alicia/git/pluralshit/TODO.org::Add `sync` command][Add `sync` command]]             |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::Add `Add` command \[0/2\]][Add `Add` command {0/2}]]        | [[/home/alicia/git/pluralshit/TODO.org::Check for mismatch in fronting between pluralkit and simplyplural][Check for mismatch in fronting]] | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add set][{SET} Add set]]                  | [[/home/alicia/git/pluralshit/TODO.org::Add new function to get the config create empty in path if not exists][Add new function to get the co]] |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add empty][{ADD} Add empty]]                |                                | [[/home/alicia/git/pluralshit/TODO.org::Compare if sent members are currently fronting and keep them otherwise add to fronting array][Compare if sent members are cu]] | [[/home/alicia/git/pluralshit/TODO.org::`Get system` if Value::Null sync and load json][`Get system` if Value::Null sy]] |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add set][{ADD} Add set]]                  |                                |                                | [[/home/alicia/git/pluralshit/TODO.org::Get current front][Get current front]]              |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::Add `setgroup` command][Add `setgroup` command]]         |                                |                                |                                |
 | 
			
		||||
|         |                         |                   |                         |                                |
 | 
			
		||||
|         |                         |                   |                         |                                |
 | 
			
		||||
|         |                         |                   |                         |                                |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::Get fronters handles the front file][Get fronters handles the front]] |                                |                                |                                |
 | 
			
		||||
|         | [[/home/alicia/git/pluralshit/TODO.org::Rofi stuff][Rofi stuff]]                     |                                |                                |                                |
 | 
			
		||||
|         |                                |                                |                                |                                |
 | 
			
		||||
|         |                                |                                |                                |                                |
 | 
			
		||||
|         |                                |                                |                                |                                |
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										99
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										99
									
								
								src/main.rs
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -73,41 +73,7 @@ fn main() {
 | 
			
		|||
}
 | 
			
		||||
// Main:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Main commands][Main commands:1]]
 | 
			
		||||
fn set_member(config_path: String, member: String) -> Result<(), &'static str> {
 | 
			
		||||
    let config = get_config(&config_path);
 | 
			
		||||
    if config == Value::Null {
 | 
			
		||||
        return Err("Config not found. Stopping");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let system: System = get_system(&config_path);
 | 
			
		||||
 | 
			
		||||
    let mut flag = false;
 | 
			
		||||
    for mem in &system.members {
 | 
			
		||||
        if mem.name.to_lowercase() == member.to_lowercase() {
 | 
			
		||||
            flag = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if flag {
 | 
			
		||||
        println!("Member {member} found");
 | 
			
		||||
        get_fronters(&config["pk_key"].as_str().unwrap(), &system.pk_userid, &config["sp_key"].as_str().unwrap(), &system);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        Ok(())
 | 
			
		||||
    } else {
 | 
			
		||||
        Err("Member {member} not found")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
fn set_empty(config_path: String) {
 | 
			
		||||
    let config = load_json(format!("{}/config.json", config_path));
 | 
			
		||||
    let system = get_system(&config_path);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Sync][Sync:1]]
 | 
			
		||||
fn sync(config_path: String) -> Result<(), String>{
 | 
			
		||||
    // Get config
 | 
			
		||||
    let config = get_config(&config_path);
 | 
			
		||||
| 
						 | 
				
			
			@ -162,9 +128,45 @@ fn sync(config_path: String) -> Result<(), String>{
 | 
			
		|||
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
// Main commands:1 ends here
 | 
			
		||||
// Sync:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Pluralkit][Pluralkit:1]]
 | 
			
		||||
// [[file:../README.org::*Set member][Set member:1]]
 | 
			
		||||
/*
 | 
			
		||||
TODO fn set_empty(config_path: String) {
 | 
			
		||||
TODO     let config = load_json(format!("{}/config.json", config_path));
 | 
			
		||||
TODO     let system = get_system(&config_path);
 | 
			
		||||
TODO }
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
fn set_member(config_path: String, member: String) -> Result<(), &'static str> {
 | 
			
		||||
    let config = get_config(&config_path);
 | 
			
		||||
    if config == Value::Null {
 | 
			
		||||
        return Err("Config not found. Stopping");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let system: System = get_system(&config_path);
 | 
			
		||||
 | 
			
		||||
    let mut flag = false;
 | 
			
		||||
    for mem in &system.members {
 | 
			
		||||
        if mem.name.to_lowercase() == member.to_lowercase() {
 | 
			
		||||
            flag = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if flag {
 | 
			
		||||
        println!("Member {member} found");
 | 
			
		||||
        get_fronters(&config["pk_key"].as_str().unwrap(), &system.pk_userid, &config["sp_key"].as_str().unwrap(), &system);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        Ok(())
 | 
			
		||||
    } else {
 | 
			
		||||
        Err("Member {member} not found")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
// Set member:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Get system][Get system:1]]
 | 
			
		||||
fn pk_get_system(key: &str) -> Value {
 | 
			
		||||
    let url = format!("{}/systems/@me", PK_URL);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -180,12 +182,15 @@ fn pk_get_members(key: &str, sysid: &str) -> Vec<Value> {
 | 
			
		|||
 | 
			
		||||
    return datas;
 | 
			
		||||
}
 | 
			
		||||
// Get system:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Get fronters][Get fronters:1]]
 | 
			
		||||
fn pk_get_fronters(key: &str, sysid: &str) -> Vec<String> {
 | 
			
		||||
    let url = format!("{}/systems/{}/fronters", PK_URL, sysid);
 | 
			
		||||
 | 
			
		||||
    let res = http_get_request(url,key);
 | 
			
		||||
    let data: Value = serde_json::from_str(&res.unwrap()).unwrap();
 | 
			
		||||
    println!("{:?}", data);
 | 
			
		||||
    let memberdata = &data["members"].as_array();
 | 
			
		||||
 | 
			
		||||
    let mut members: Vec<String> = Vec::new();
 | 
			
		||||
| 
						 | 
				
			
			@ -198,9 +203,9 @@ fn pk_get_fronters(key: &str, sysid: &str) -> Vec<String> {
 | 
			
		|||
 | 
			
		||||
    return members;
 | 
			
		||||
}
 | 
			
		||||
// Pluralkit:1 ends here
 | 
			
		||||
// Get fronters:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Simplyplural][Simplyplural:1]]
 | 
			
		||||
// [[file:../README.org::*Get user ID][Get user ID:1]]
 | 
			
		||||
fn sp_get_userid(key: &str) -> String {
 | 
			
		||||
    let url = format!("{}/me", SP_URL);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +213,9 @@ fn sp_get_userid(key: &str) -> String {
 | 
			
		|||
    let json_res : Value = serde_json::from_str(&res.unwrap()).unwrap();
 | 
			
		||||
    return json_res["id"].as_str().unwrap().to_string();
 | 
			
		||||
}
 | 
			
		||||
// Get user ID:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Get members ID][Get members ID:1]]
 | 
			
		||||
fn sp_get_memberids(key: &str, system_id: &str) -> HashMap<String, String> {
 | 
			
		||||
    let url = format!("{}/members/{}", SP_URL, system_id);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -222,7 +229,9 @@ fn sp_get_memberids(key: &str, system_id: &str) -> HashMap<String, String> {
 | 
			
		|||
 | 
			
		||||
    return sp_memberdata;
 | 
			
		||||
}
 | 
			
		||||
// Get members ID:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Get ID from member][Get ID from member:1]]
 | 
			
		||||
fn get_sp_id(mem: &Member, ids: &HashMap<String, String>) -> String {
 | 
			
		||||
 | 
			
		||||
    let mut member_id = String::new();
 | 
			
		||||
| 
						 | 
				
			
			@ -235,7 +244,9 @@ fn get_sp_id(mem: &Member, ids: &HashMap<String, String>) -> String {
 | 
			
		|||
 | 
			
		||||
    return member_id;
 | 
			
		||||
}
 | 
			
		||||
// Get ID from member:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Get fronters][Get fronters:1]]
 | 
			
		||||
fn sp_get_fronters(key: &str, sys: &System) -> Vec<String> {
 | 
			
		||||
    let url = format!("{}/fronters", SP_URL);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -256,9 +267,9 @@ fn sp_get_fronters(key: &str, sys: &System) -> Vec<String> {
 | 
			
		|||
    }
 | 
			
		||||
    return members;
 | 
			
		||||
}
 | 
			
		||||
// Simplyplural:1 ends here
 | 
			
		||||
// Get fronters:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Utilities][Utilities:1]]
 | 
			
		||||
// [[file:../README.org::*Load JSON][Load JSON:1]]
 | 
			
		||||
fn load_json(path: String) -> Value {
 | 
			
		||||
    if Path::new(&path).exists() {
 | 
			
		||||
        let config_data = fs::read_to_string(&path).expect("File not found");
 | 
			
		||||
| 
						 | 
				
			
			@ -268,7 +279,9 @@ fn load_json(path: String) -> Value {
 | 
			
		|||
        return Value::Null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
// Load JSON:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Get config json][Get config json:1]]
 | 
			
		||||
fn get_config(config_path: &str) -> Value {
 | 
			
		||||
    let path = format!("{}/config.json", config_path);
 | 
			
		||||
    if Path::new(config_path).exists() {
 | 
			
		||||
| 
						 | 
				
			
			@ -298,7 +311,9 @@ fn get_config(config_path: &str) -> Value {
 | 
			
		|||
        return Value::Null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
// Get config json:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Get system json][Get system json:1]]
 | 
			
		||||
fn get_system(config_path: &str) -> System {
 | 
			
		||||
    let path = format!("{}/system.json", config_path);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -325,7 +340,7 @@ fn get_fronters(pk_key: &str, pk_sysid: &str, sp_key: &str, sys: &System) -> Has
 | 
			
		|||
 | 
			
		||||
    return fronters;
 | 
			
		||||
}
 | 
			
		||||
// Utilities:1 ends here
 | 
			
		||||
// Get system json:1 ends here
 | 
			
		||||
 | 
			
		||||
// [[file:../README.org::*Http Request handler][Http Request handler:1]]
 | 
			
		||||
#[tokio::main]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue