Sublime Forum

Command line arguments to plugins

#1

To send commands to a plugin from the command line, I know you can do the following:

subl --command my_plugin_command

Is there a way to pass arguments to this? All of the variants I’ve tried either try to open files named like the passed arguments, or give the message “Unable to parse command: …”. The only thing that doesn’t error so far is:
subl --command “my_plugin_command {}”

Anything placed inside of the {} causes the “Unable to parse command” error.

0 Likes

#2

??
May be you have a wrong function call?

Here an example from my Plugins, that works fine.

The Plugin:

class ViewInsertCommand(sublime_plugin.TextCommand): def run(self, edit, pos, text): self.view.insert(edit, pos, text)

The call:

self.view.run_command("view_insert", {"pos": pos, "text": self.macro_list[selection][0]})

0 Likes

#3

Turns out you need quotes for the arugments, and they need to be escaped. The following works:

subl --command "my_plugin_command {\"somearg\": \"String passed as somearg\"}"
1 Like

Read-only Instruction out of the cmd line
Is there any AppleScript (or literally any language) support for accessing the python console from outside Sublime?