message: allow plugins to edit commands at any time
diff: @@ -31,8 +31,17 @@ router.get('/tab', (_req, res) => {
  }
  })
  +router.get('/command', (_req, res) => {
  + const test = UiState.displayedTest
  + if (test) {
  + res({ commands: test.commands.map(cmd => cmd.export()) })
  + } else {
  + res({ status: 'error', message: 'No test selected' })
  + }
  +})
  +
  router.post('/command', (req, res) => {
  - recordCommand(req.command, req.target, req.value, undefined, req.select)
  + recordCommand(req.command, req.target, req.value, req.index, req.select)
  const type =
  Commands.list.has(req.command) && Commands.list.get(req.command).type
  if (req.select && type) {
  @@ -41,4 +50,30 @@ router.post('/command', (req, res) => {
  res(true)
  })
  +router.put('/command', (req, res) => {
  + if (!req.id) {
  + res({ status: 'error', message: 'No id sent' })
  + } else {
  + const test = UiState.displayedTest
  + if (test) {
  + const command = test.commands.find(cmd => cmd.id === req.id)
  + if (command) {
  + command.setCommand(req.command || '')
  + command.setTarget(req.target || '')
  + command.setValue(req.value || '')
  + command.setTargets(Array.isArray(req.targets) ? req.targets : [])
  + res(true)
  + } else {
  + res({
  + status: 'error',
  + message:
  + 'No command with that id exists in the currently displayed test',
  + })
  + }
  + } else {
  + res({ status: 'error', message: 'No test selected' })
  + }
  + }
  +})
  +
  export default router
  