Capture values followed by a textarea in the same function

1

I'm developing a console with HTML5 + Vue to streamline some simple commands.

The inserted command comes via a textarea with v-model="cmd" v-on:keyup.enter="consoleMode()" .

I'm using else else, since I only need 4 functions.

consoleMode: function(cmd){
  this.cmdHistory.push({command: this.cmd})
  if(this.cmd == 'cls\n'){
    this.cmdHistory = [{command: 'início'}]
  } else if(this.cmd == 'add client\n'){
    this.cmdQuest = 'Qual o nome do cliente?'
    //ler a primeira resposta e fazer outras perguntas
  } else if(this.cmd == 'exit\n'){
    this.cmdQuest = ''
  }
  this.cmd = ''
}

I caught the first question, because I have no idea how I can capture some values in the scanf style in C with this textarea.

Basically, I need this if it captures 4 values in a row (one by one, always clearing the textarea), and throws it in a newClient object, alternating the value of this.cmdQuest for each new line ("What's the name? "," What is the CPF? ", Etc.).

If there is any plugin to help with this, it would be cool.

EDIT1: this.cmdHistory is an array with objects type {command: 'my last command'} link

    
asked by anonymous 03.08.2017 / 20:49

0 answers