memberlist command

This commit is contained in:
Junko 2023-11-22 11:24:05 +01:00
parent cc8f3c919d
commit f087dcf3c2
3 changed files with 61 additions and 23 deletions

View File

@ -98,6 +98,7 @@ fn main() {
//set_empty(config_path);
}
},
"memberlist" => memberlist(config_path),
&_ => println!("Invalid command"),
}
},
@ -171,7 +172,6 @@ fn sync(config_path: String) -> Result<(), String>{
***** 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));
@ -204,6 +204,15 @@ fn set_member(config_path: String, member: String) -> Result<(), &'static str> {
Err("Member {member} not found")
}
}
fn memberlist(config_path: String) {
let sys = get_system(&config_path);
for mem in sys.members {
println!("{}", mem.name);
}
}
#+end_src
@ -252,12 +261,25 @@ fn pk_get_fronters(key: &str, sysid: &str) -> Vec<String> {
**** 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);
fn sp_get_fronters(key: &str, sys: &System) -> Vec<String> {
let url = format!("{}/fronters", SP_URL);
let res = http_get_request(url,key);
let json_res : Value = serde_json::from_str(&res.unwrap()).unwrap();
return json_res["id"].as_str().unwrap().to_string();
let datas: Vec<Value> = serde_json::from_str(&res.unwrap()).unwrap();
let mut members: Vec<String> = Vec::new();
for data in datas {
let sp_id = &data["content"]["member"].as_str().unwrap();
let mut push_name = String::new();
for member in &sys.members {
if &member.sp_id == sp_id {
push_name = String::from(&member.name);
}
}
members.push(push_name);
}
return members;
}
#+end_src

View File

@ -8,38 +8,44 @@
:PROPERTIES:
:COOKIE_DATA: recursive
:END:
*** Milestone 1.0 [4/16][25%]
**** Main functions [1/9][11%]
*** Milestone 1.0 [5/20][25%]
**** Main functions [2/10][20%]
***** Finished Add `sync` command
***** InProgress Add `set` command [0/2]
****** HighPriority [SET] Add empty
****** LowPriority [SET] Add empty
****** InProgress [SET] Add set
***** LowPriority Add `get` command
***** LowPriority Add `Add` command [0/2]
***** LowPriority Add `add` command [0/2]
****** LowPriority [ADD] Add empty
****** LowPriority [ADD] Add set
***** LowPriority Add `setgroup` command
**** Utils [3/7][42%]
***** Finished Add `memberlist` command
**** Utils [3/9][33%]
***** 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
***** Finished Get current front
***** InProgress Compare if sent members are currently fronting and keep them otherwise add to fronting array
***** InProgress http PATCH request
***** InProgress http POST request
***** HighPriority 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
**** Doc [0/1][0%]
***** Functions [0/1]
****** Backlog separate memberlist into its own code block in the readme
** Kanban
| Backlog | LowPriority | HighPriority | InProgress | Finished |
|---------+--------------------------------+--------------------------------+--------------------------------+--------------------------------|
| | [[/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]] | | | |
| | | | | |
| | | | | |
| | | | | |
| Backlog | LowPriority | HighPriority | InProgress | Finished |
|--------------------------------+--------------------------------+--------------------------------+-------------------------+--------------------------------|
| [[/home/alicia/git/pluralshit/TODO.org::separate memberlist into its own code block in the readme][separate memberlist into its o]] | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add empty][{SET} 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::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 `get` command][Add `get` command]] | [[/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 `memberlist` command][Add `memberlist` command]] |
| | [[/home/alicia/git/pluralshit/TODO.org::Add `add` command \[0/2\]][Add `add` command {0/2}]] | | [[/home/alicia/git/pluralshit/TODO.org::http PATCH request][http PATCH request]] | [[/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::http POST request][http POST request]] | [[/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]] | | | |
| | | | | |
| | | | | |
#+TBLFM: @1='(kanban-headers $#)::@2$1..@>$>='(kanban-zero @# $# nil (list (buffer-file-name)))

View File

@ -62,6 +62,7 @@ fn main() {
//set_empty(config_path);
}
},
"memberlist" => memberlist(config_path),
&_ => println!("Invalid command"),
}
},
@ -163,6 +164,15 @@ fn set_member(config_path: String, member: String) -> Result<(), &'static str> {
Err("Member {member} not found")
}
}
fn memberlist(config_path: String) {
let sys = get_system(&config_path);
for mem in sys.members {
println!("{}", mem.name);
}
}
// Set member:1 ends here