From 0bd0eb19ed52990b248328e5a33546f9560212cd Mon Sep 17 00:00:00 2001 From: Noor Date: Mon, 24 Mar 2025 17:29:40 +0530 Subject: [PATCH] feat: add --as-operator flag to list command for apps --- src/bin/detee-cli.rs | 6 ++++++ src/sgx/cli_handler.rs | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/bin/detee-cli.rs b/src/bin/detee-cli.rs index ecb5a29..549b0e1 100644 --- a/src/bin/detee-cli.rs +++ b/src/bin/detee-cli.rs @@ -277,6 +277,12 @@ fn clap_cmd() -> Command { Command::new("list") .about("list all deployed apps") .long_about("List all the deployed apps in the enclave") + .arg( + Arg::new("as-operator") + .long("as-operator") + .help("list Apps running on your SGX nodes") + .action(clap::ArgAction::SetTrue) + ) ) ) .subcommand(Command::new("app-node") diff --git a/src/sgx/cli_handler.rs b/src/sgx/cli_handler.rs index babbf48..51ee520 100644 --- a/src/sgx/cli_handler.rs +++ b/src/sgx/cli_handler.rs @@ -26,7 +26,7 @@ pub fn handle_app(app_matche: &ArgMatches) { Some(("deploy", subcom_args)) => cli_print(handle_deploy(subcom_args)), Some(("inspect", subcom_args)) => handle_inspect(subcom_args), Some(("delete", subcom_args)) => cli_print(handle_delete(subcom_args)), - Some(("list", _)) => cli_print(handle_list()), + Some(("list", subcom_args)) => cli_print(handle_list(subcom_args)), Some(("config", subcom_args)) => handle_config(subcom_args), _ => println!("No valid subcommand provided. Use --help for more information."), } @@ -170,9 +170,19 @@ fn handle_delete( } } -fn handle_list() -> Result, Box> { - let req = - ListAppContractsReq { admin_pubkey: Config::get_detee_wallet()?, ..Default::default() }; +fn handle_list(list_matche: &ArgMatches) -> Result, Box> { + let as_operator = *list_matche.get_one::("as-operator").unwrap_or(&false); + + let req = if as_operator { + ListAppContractsReq { + admin_pubkey: Config::get_detee_wallet()?, + as_operator, + ..Default::default() + } + } else { + ListAppContractsReq { admin_pubkey: Config::get_detee_wallet()?, ..Default::default() } + }; + let contracts: Vec = block_on(list_contracts(req))?.into_iter().map(|n| n.into()).collect();