accelerator/runtime_cli.c
static void handle_command(char *str) {
  char *cmd;

  if (extract_one(&str, &cmd)) {
    bool matched = false;
    for (size_t i = 0; i < ta_state_ptr->size; ++i) {
      ta_cli_cmd list_cmd = ta_state_ptr->list[i];
      if (!strncmp(list_cmd.name, cmd, 128)) {
        if (list_cmd.type == CMD_LAST) {
          list_cmd.fn(str);
          matched = true;
          break;
        } else if (list_cmd.type == CMD_STATE) {
          ta_state_ptr = list_cmd.next_state;
          handle_command(str);
          matched = true;
          break;
        }
      }
    }
    if (!matched) do_help("");
  } else {
    do_help("");
  }
}
/**
 * @brief Handle the command
 *
 * This function first extracts one subcommand from the original command, then find one
 * matching name according to the current state (maintained by `ta_state_ptr`).
 *
 * If matched, determine whether the state type is CMD_LAST (to execute function) or
 * CMD_STATE (to step to next state).
 *
 * If not matched, print help message of current state.
 *
 */
@brief Handle the command
This function first extracts one subcommand from the original command, then find one
matching name according to the current state (maintained by `ta_state_ptr`).

If matched, determine whether the state type is CMD_LAST (to execute function) or
CMD_STATE (to step to next state).

If not matched, print help message of current state.
@brief Handle the command This function first extracts one subcommand from the original command then find one matching name according to the current state ( maintained by ` ta_state_ptr ` ) . If matched determine whether the state type is CMD_LAST ( to execute function ) or CMD_STATE ( to step to next state ) . If not matched print help message of current state .
static void handle_command(char *str) {
  char *cmd;
  if (extract_one(&str, &cmd)) {
    bool matched = false;
    for (size_t i = 0; i < ta_state_ptr->size; ++i) {
      ta_cli_cmd list_cmd = ta_state_ptr->list[i];
      if (!strncmp(list_cmd.name, cmd, 128)) {
        if (list_cmd.type == CMD_LAST) {
          list_cmd.fn(str);
          matched = true;
          break;
        } else if (list_cmd.type == CMD_STATE) {
          ta_state_ptr = list_cmd.next_state;
          handle_command(str);
          matched = true;
          break;
        }
      }
    }
    if (!matched) do_help("");
  } else {
    do_help("");
  }
}
static void handle_command ( char * str ) { char * cmd ; if ( extract_one ( & str , & cmd ) ) { bool matched = false ; for ( size_t i = 0 ; i < ta_state_ptr -> size ; ++ i ) { ta_cli_cmd list_cmd = ta_state_ptr -> list [ i ] ; if ( ! strncmp ( list_cmd . name , cmd , 128 ) ) { if ( list_cmd . type == CMD_LAST ) { list_cmd . fn ( str ) ; matched = true ; break ; } else if ( list_cmd . type == CMD_STATE ) { ta_state_ptr = list_cmd . next_state ; handle_command ( str ) ; matched = true ; break ; } } } if ( ! matched ) do_help ( " " ) ; } else { do_help ( " " ) ; } }
@brief Handle the command
 This function first extracts one subcommand from the original command, then find one
 matching name according to the current state (maintained by `ta_state_ptr`).
@brief Handle the command This function first extracts one subcommand from the original command then find one matching name according to the current state ( maintained by ` ta_state_ptr ` ) .