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

FileContentCommand component

Obtain the file content of the remote session.
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
Its reference example:
https://github.com/aoyiduo/woterm/blob/main/private/playbooks/test/TestFileContentCommand.qml

The core code is as follows:

import FileContentCommand 1.0

FileContentCommand {
   id: fileContent
}

asyncGenerator(function*(){
    fileContent.hosts = hosts.text.split(',')
    yield fileContentCommand(fileContent, fileRemote.text, true)
    Playbook.log("fileRead", fileContent.content);
})()

The Property list is as follows:
QString filePath:[readable / writable], Set the path for remote files.
bool fileRead:[readable / writable], Set the file read and write mode, with a value of true to read the file content and a value of false to write the file content.
int maxFileSize: [readable / writable], When reading mode, only the maximum length of content can be read; When in write mode, if the content length exceeds this length, the write fails.
QByteArray content: [readable], File content.