Skip to content

Commit bf95fdd

Browse files
committed
feat: add list_projects command
1 parent 9d46805 commit bf95fdd

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

src/commands/list_projects.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use super::*;
2+
use crate::utils::config::Config;
3+
4+
#[derive(Parser)]
5+
pub struct Args {}
6+
7+
pub async fn command(_args: Args, config: Config) -> Result<()> {
8+
let key = config.primary_key()?;
9+
let password = config.primary_key_password()?;
10+
let key = key.unlock(&password);
11+
let sdk_config = config.sdk_configuration(&key)?;
12+
let projects =
13+
envx_sdk::apis::projects_api::list_projects_v2(&sdk_config).await?;
14+
15+
println!("Projects:");
16+
for project in projects {
17+
println!("\t{} - {}", project.project_id, project.project_name);
18+
}
19+
Ok(())
20+
}

src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod gen;
1515
pub mod import;
1616
pub mod link;
1717
pub mod list_keys;
18+
pub mod list_projects;
1819
pub mod run;
1920
pub mod set;
2021
pub mod shell;

src/main.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,28 @@ pub struct Args {
3030
// Generates the commands based on the modules in the commands directory
3131
// Specify the modules you want to include in the commands_enum! macro
3232
commands_enum!(
33-
auth, export, gen, import, link, list_keys, run, set, shell, unlink, unset,
34-
update, upload, variables, version, whoami,
33+
auth,
34+
export,
35+
gen,
36+
import,
37+
link,
38+
list_keys,
39+
list_projects,
40+
run,
41+
set,
42+
shell,
43+
unlink,
44+
unset,
45+
update,
46+
upload,
47+
variables,
48+
version,
49+
whoami,
3550
// commands with subcommands
36-
config, get, keyring, project
51+
config,
52+
get,
53+
keyring,
54+
project
3755
);
3856

3957
fn spawn_update_task() -> tokio::task::JoinHandle<anyhow::Result<String>> {

0 commit comments

Comments
 (0)