Commands

Permissions

By default, Seanime disallows running commands, you must manually defines the command and arguments your plugin will want to run using commandScopes .

Example

{
  // ...
  "plugin": {
    "permissions": {
      "allow": {
        "readPaths": ["$DOWNLOAD"],
        "writePaths": ["$DOWNLOAD"]
      },
      "commandScopes": [
        {
          "command": "ls",
          "args": [{ "value": "-la" }, { "validator": "$PATH" }]
        },
        {
          "command": "grep",
          "args": [{ "value": "Hello" }, { "validator": "$PATH" }]
        },
        {
          "command": "sort",
          "args": []
        },
        {
          "command": "echo",
          "args": [{ "validator": "$ARGS" }]
        },
        {
          "command": "open",
          "args": [{ "validator": "^https?://.*$" }]
        }
      ]
    }
  }
}

This example shows:

  • The ls command can be executed with the -la argument followed by a valid file/directory path $PATH. This path must be in the allow list for write . $PATH is an alternative to writing the regex.

  • The grep command is allowed with the "Hello" argument and a similar path validation.

  • The sort command is permitted without any additional arguments.

  • The echo command is allowed with any argument or list of arguments.

  • The open command is allowed with any valid URLs

Command (sync)

The code below shows how to run a command with the caveat that this approach will block the plugin's UI context thread until the command finishes running.

Command (async)

If you need to run a command without blocking the plugin's UI context thread, you should use $osExtra.asyncCmd .

Do not use both sync and async commands in the same plugin as this can cause some data race issues.

Last updated