refactor: handle_vm_nodes function to snp cli handler
This commit is contained in:
		
							parent
							
								
									30fc217ac3
								
							
						
					
					
						commit
						de8f761e1f
					
				| @ -1,7 +1,7 @@ | ||||
| use clap::{builder::PossibleValue, Arg, ArgMatches, Command}; | ||||
| use clap_complete::{generate, Shell}; | ||||
| use detee_cli::sgx::cli_handler::handle_app; | ||||
| use detee_cli::snp::cli_handler::handle_vm; | ||||
| use detee_cli::snp::cli_handler::{handle_vm, handle_vm_nodes}; | ||||
| use detee_cli::*; | ||||
| use std::error::Error; | ||||
| use std::io; | ||||
| @ -599,26 +599,6 @@ fn handle_completion(matches: &ArgMatches, cmd: Command) { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| fn handle_vm_nodes(matches: &ArgMatches) { | ||||
|     match matches.subcommand() { | ||||
|         Some(("search", _)) => cli_print(snp::print_nodes().map_err(Into::into)), | ||||
|         Some(("inspect", path_subcommand)) => { | ||||
|             let ip: String = path_subcommand.get_one::<String>("ip").unwrap().clone(); | ||||
|             cli_print(snp::inspect_node(ip).map_err(Into::into)); | ||||
|         } | ||||
|         Some(("report", path_subcommand)) => { | ||||
|             let node_pubkey: String = path_subcommand.get_one::<String>("pubkey").unwrap().clone(); | ||||
|             let contract_uuid: String = | ||||
|                 path_subcommand.get_one::<String>("contract").unwrap().clone(); | ||||
|             let reason: String = path_subcommand.get_one::<String>("reason").unwrap().clone(); | ||||
|             cli_print(snp::report_node(node_pubkey, contract_uuid, reason).map_err(Into::into)) | ||||
|         } | ||||
|         _ => { | ||||
|             println!("Available commands are search and report. Use --help for more information.") | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| fn handle_account(matches: &ArgMatches) { | ||||
|     match matches.subcommand() { | ||||
|         Some(("show", _)) => cli_print(Ok(config::Config::get_account_data())), | ||||
|  | ||||
| @ -24,6 +24,27 @@ pub fn handle_vm(matches: &ArgMatches) { | ||||
|         _ => println!("No valid VM subcommand provided."), | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| pub fn handle_vm_nodes(matches: &ArgMatches) { | ||||
|     match matches.subcommand() { | ||||
|         Some(("search", _)) => cli_print(snp::print_nodes().map_err(Into::into)), | ||||
|         Some(("inspect", path_subcommand)) => { | ||||
|             let ip: String = path_subcommand.get_one::<String>("ip").unwrap().clone(); | ||||
|             cli_print(snp::inspect_node(ip).map_err(Into::into)); | ||||
|         } | ||||
|         Some(("report", path_subcommand)) => { | ||||
|             let node_pubkey: String = path_subcommand.get_one::<String>("pubkey").unwrap().clone(); | ||||
|             let contract_uuid: String = | ||||
|                 path_subcommand.get_one::<String>("contract").unwrap().clone(); | ||||
|             let reason: String = path_subcommand.get_one::<String>("reason").unwrap().clone(); | ||||
|             cli_print(snp::report_node(node_pubkey, contract_uuid, reason).map_err(Into::into)) | ||||
|         } | ||||
|         _ => { | ||||
|             println!("Available commands are search and report. Use --help for more information.") | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| fn handle_vm_deploy(matches: &ArgMatches) -> Result<snp::VmSshArgs, Box<dyn Error>> { | ||||
|     if let Some(path) = matches.get_one::<String>("yaml-path") { | ||||
|         return Ok(snp::deploy::Request::load_from_yaml(path)?); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user