forked from ziglang/sublime-zig-language
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMultiCommand.py
28 lines (23 loc) · 901 Bytes
/
MultiCommand.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# multi_command.py
import sublime, sublime_plugin
# Takes an array of commands (same as those you'd provide to a key binding) with
# an optional context (defaults to view commands) & runs each command in order.
# Valid contexts are 'text', 'window', and 'app' for running a TextCommand,
# WindowCommands, or ApplicationCommand respectively.
class MulticommandCommand(sublime_plugin.TextCommand):
def exec_command(self, command):
if not 'command' in command:
raise Exception('No command name provided.')
args = None
if 'args' in command:
args = command['args']
# skip args if not needed
if args is None:
sublime.active_window().run_command(command['command'])
else:
sublime.active_window().run_command(command['command'], args)
def run(self, edit, commands = None):
if commands is None:
return # not an error
for command in commands:
self.exec_command(command)