public async commandLetLoop()

in packages/orchestratorlib/src/predict.ts [463:568]


  public async commandLetLoop(): Promise<number> {
    /** ---- NOTE ----
     *  need to dynamically create an 'interactive' object
     *  and call close() when it's not needed, otherwise this resource cannot be
     *  properly disposed of and a unit test on this object will hang.
     */
    try {
      this.trackEventFunction(`${this.cliCmmandId}:commandLetLoop`, {callee: 'commandLetLoop'});
    } catch (error) {
    }
    const interactive: readline.Interface = readline.createInterface(process.stdin, process.stdout);
    const question: any = function (prefix: string) {
      return new Promise((resolve: any, _reject: any) => {
        interactive.question(prefix, (answer: string) => {
          resolve(answer);
        });
      });
    };
    let command: string = '';
    // ---- NOTE ---- enter the interaction loop.
    // eslint-disable-next-line no-constant-condition
    while (true) {
      this.displayInputs();
      // eslint-disable-next-line no-await-in-loop
      command = await question(OrchestratorPredict.commandprefix);
      command = command.trim();
      Utility.debuggingLog(`The command you entered is "${command}"`);
      if (command === 'q') {
        break;
      }
      switch (command) {
        case 'h': this.commandLetH();
          break;
        case 'd': this.commandLetD();
          break;
        case 's': this.commandLetS();
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'u': await this.commandLetU(question);
          break;
        case 'cu': this.commandLetCU();
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'i': await this.commandLetI(question);
          break;
        case 'ci': this.commandLetCI();
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'ni': await this.commandLetNI(question);
          break;
        case 'cni': this.commandLetCNI();
          break;
        case 'f': this.commandLetF();
          break;
        case 'p': this.commandLetP();
          break;
        case 'v': this.commandLetV();
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vd': await this.commandLetVD(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'va': await this.commandLetVA(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vm': await this.commandLetVM(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vl': await this.commandLetVL(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vat': await this.commandLetVAT(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vlt': await this.commandLetVLT(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vmt': await this.commandLetVMT(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vut': await this.commandLetVUT(question);
          break;
        // eslint-disable-next-line no-await-in-loop
        case 'vo': await this.commandLetVO(question);
          break;
        case 'a': this.commandLetA();
          break;
        case 'r': this.commandLetR();
          break;
        case 'c': this.commandLetC();
          break;
        case 'rl': this.commandLetRL();
          break;
        case 'n': this.commandLetN();
          break;
        default:
          console.log(`> Cannot recognize the command you just entered "${command}",`);
          console.log('> please type "h" for help!');
          break;
      }
    }
    // eslint-disable-next-line no-console
    console.log('> Bye!');
    interactive.close();
    return 0;
  }