-
Notifications
You must be signed in to change notification settings - Fork 1
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
6 changed files
with
93 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
pub use crate::commands::get::keys::{command, Args}; |
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
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,67 @@ | ||
use super::*; | ||
use crate::types::PartialUser; | ||
use crate::utils::config::get_config; | ||
use crate::{sdk::SDK, utils::choice::Choice}; | ||
|
||
/// Get all environment variables for a project | ||
#[derive(Parser)] | ||
pub struct Args { | ||
/// Partial fingerprint of key to use | ||
#[clap(short, long)] | ||
key: Option<String>, | ||
|
||
/// Project ID | ||
#[clap(short, long)] | ||
project_id: Option<String>, | ||
|
||
/// Output in JSON format | ||
#[clap(long)] | ||
json: bool, | ||
|
||
/// Show all info | ||
#[clap(short, long)] | ||
all: bool, | ||
} | ||
|
||
// TODO: Pretty print project info (in a table?) | ||
pub async fn command(args: Args) -> Result<()> { | ||
let config = get_config()?; | ||
let key = config.get_key_or_default(args.key)?; | ||
let project_id = | ||
Choice::try_project(args.project_id, &key.fingerprint).await?; | ||
let project_info = | ||
SDK::get_project_info(&project_id, &key.fingerprint).await?; | ||
|
||
if args.json && args.all { | ||
println!("{}", serde_json::to_string(&project_info.users)?); | ||
return Ok(()); | ||
} | ||
|
||
if args.json { | ||
println!( | ||
"{}", | ||
serde_json::to_string( | ||
&project_info | ||
.users | ||
.iter() | ||
.map(|u| u.clone().into()) | ||
.collect::<Vec<PartialUser>>() | ||
)? | ||
); | ||
return Ok(()); | ||
} | ||
|
||
if args.all { | ||
for user in project_info.users.iter() { | ||
println!("{} - {} - {} - {}", user.username, user.id, user.created_at, user.public_key); | ||
} | ||
println!("{:?}", &project_info.users); | ||
return Ok(()); | ||
} | ||
|
||
for user in project_info.users.iter() { | ||
println!("{}", user); | ||
} | ||
|
||
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
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 |
---|---|---|
|
@@ -34,6 +34,7 @@ commands_enum!( | |
gen, | ||
import, | ||
link, | ||
list_keys, | ||
run, | ||
set, | ||
shell, | ||
|
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