1. Home
  2. Docs
  3. Manual
  4. Playbook
  5. Command list
  6. LocalCommand component

LocalCommand component

This is the command interface for executing local terminals, which will exit terminal mode after each command execution is completed.
Because it is executed asynchronously, in order to facilitate collaboration with async/await, a JS interface with the same name but lowercase initial is encapsulated. The specific source code is as follows:
https://github.com/aoyiduo/woterm/blob/main/woterm/js/async.js
And its reference example:
https://github.com/aoyiduo/woterm/blob/main/private/playbooks/test/TestLocalCommand.qml

The core code is as follows:

import LocalCommand 1.0

LocalCommand {
   id: local
   onDataArrived: {
      Playbook.log(data)
   }
}

asyncGenerator(function *(){
    Playbook.log("command start.")
    yield localCommand(local, cmd.text).catch(function(){})
    Playbook.log("command finish.")
})();

The Property list is as follows:
QString command: [readable / writable], setting the commands to be executed.
Int lastExitCode: [readable], get the exit code at the end of the command’s final execution. Typically, an exit code of 0 is normal, while other values indicate exceptions.