feat: add --as-operator flag to list command for apps
This commit is contained in:
		
							parent
							
								
									7d7200bca4
								
							
						
					
					
						commit
						0bd0eb19ed
					
				| @ -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") | ||||
|  | ||||
| @ -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<Vec<AppContract>, Box<dyn std::error::Error>> { | ||||
|     let req = | ||||
|         ListAppContractsReq { admin_pubkey: Config::get_detee_wallet()?, ..Default::default() }; | ||||
| fn handle_list(list_matche: &ArgMatches) -> Result<Vec<AppContract>, Box<dyn std::error::Error>> { | ||||
|     let as_operator = *list_matche.get_one::<bool>("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<AppContract> = | ||||
|         block_on(list_contracts(req))?.into_iter().map(|n| n.into()).collect(); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user