MCPcopy Create free account
hub / github.com/BitVM/BitVM / handle_interactive_command

Method handle_interactive_command

bridge/src/client/cli/client_command.rs:541–621  ·  view source on GitHub ↗
(&mut self, main_command: &Command)

Source from the content-addressed store, hash-verified

539 }
540
541 pub async fn handle_interactive_command(&mut self, main_command: &Command) -> io::Result<()> {
542 println!(
543 "{}",
544 "Entering interactive mode. Type 'help' for a list of commands and 'exit' to quit."
545 .green()
546 );
547
548 let mut stdin_reader = BufReader::new(tokio::io::stdin());
549 loop {
550 print!("{}", "bitvm >> ".bold());
551 io::stdout().flush().unwrap(); // Ensure the prompt is printed out immediately
552
553 let mut line = String::new();
554 stdin_reader.read_line(&mut line).await.unwrap();
555 let input = line.trim();
556
557 if input == "exit" {
558 break;
559 }
560
561 let mut args = vec!["bitvm"];
562 args.extend(input.split_whitespace());
563
564 let matches = match main_command.clone().try_get_matches_from(args) {
565 Ok(matches) => matches,
566 Err(e) => {
567 if !e.to_string().to_lowercase().contains("error") {
568 println!("{}", format!("{}", e).green());
569 } else {
570 println!("{}", format!("{}", e).red());
571 }
572 continue;
573 }
574 };
575
576 if let Some(sub_matches) = matches.subcommand_matches("keys") {
577 let key_dir = matches.get_one::<String>("key-dir").cloned();
578 let keys_command = KeysCommand::new(key_dir);
579 keys_command.handle_command(sub_matches)?;
580 } else if matches.subcommand_matches("get-operator-address").is_some() {
581 self.handle_get_operator_address().await?;
582 } else if matches.subcommand_matches("get-operator-utxos").is_some() {
583 self.handle_get_operator_utxos().await?;
584 } else if matches
585 .subcommand_matches("get-depositor-address")
586 .is_some()
587 {
588 self.handle_get_depositor_address().await?;
589 } else if matches.subcommand_matches("get-depositor-utxos").is_some() {
590 self.handle_get_depositor_utxos().await?;
591 } else if let Some(sub_matches) = matches.subcommand_matches("initiate-peg-in") {
592 self.handle_initiate_peg_in_command(sub_matches).await?;
593 } else if let Some(sub_matches) = matches.subcommand_matches("create-peg-out") {
594 self.handle_create_peg_out_graph_command(sub_matches)
595 .await?;
596 } else if let Some(sub_matches) = matches.subcommand_matches("push-nonces") {
597 self.handle_push_nonces_command(sub_matches).await?;
598 } else if let Some(sub_matches) = matches.subcommand_matches("push-signatures") {

Callers 1

mainFunction · 0.80

Tested by

no test coverage detected