-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod item; | ||
pub mod user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::error; | ||
use std::option; | ||
use std::string; | ||
|
||
pub fn execute_list_user_command() -> Result<(), Box<dyn error::Error>> { | ||
// Retrieve JSON | ||
let stdout = match crate::command::execute_command_stdout( | ||
"op", | ||
vec!["list".to_string(), "users".to_string()], | ||
) { | ||
Ok(out) => out, | ||
Err(e) => return Err(e), | ||
}; | ||
parse_list_user_output(stdout) | ||
} | ||
|
||
fn parse_list_user_output(output: String) -> Result<(), Box<dyn error::Error>> { | ||
let list: Vec<crate::command::OpUser> = serde_json::from_str(&output)?; | ||
for (i, user) in list.iter().enumerate() { | ||
println!("UUID: {}", user.uuid); | ||
println!("First Name: {}", user.firstName); | ||
if i < list.len() - 1 { | ||
println!("Email: {}\r\n", user.email); | ||
} else { | ||
println!("Email: {}", user.email); | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters