Merge :run-userscripts into :spawn.
:run-userscripts is now marked as deprecated, and :spawn has a new -u/--userscript option instead. Closes #448.
This commit is contained in:
parent
a32f1e6180
commit
4485e4ee1b
@ -32,7 +32,6 @@
|
||||
|<<repeat,repeat>>|Repeat a given command.
|
||||
|<<report,report>>|Report a bug in qutebrowser.
|
||||
|<<restart,restart>>|Restart qutebrowser while keeping existing tabs open.
|
||||
|<<run-userscript,run-userscript>>|Run an userscript given as argument.
|
||||
|<<save,save>>|Save the config file.
|
||||
|<<search,search>>|Search for a text on the current page.
|
||||
|<<set,set>>|Set an option.
|
||||
@ -351,16 +350,6 @@ Report a bug in qutebrowser.
|
||||
=== restart
|
||||
Restart qutebrowser while keeping existing tabs open.
|
||||
|
||||
[[run-userscript]]
|
||||
=== run-userscript
|
||||
Syntax: +:run-userscript 'cmd' ['args' ['args' ...]]+
|
||||
|
||||
Run an userscript given as argument.
|
||||
|
||||
==== positional arguments
|
||||
* +'cmd'+: The userscript to run.
|
||||
* +'args'+: Arguments to pass to the userscript.
|
||||
|
||||
[[save]]
|
||||
=== save
|
||||
Save the config file.
|
||||
@ -404,7 +393,7 @@ Preset the statusbar to some text.
|
||||
|
||||
[[spawn]]
|
||||
=== spawn
|
||||
Syntax: +:spawn 'args' ['args' ...]+
|
||||
Syntax: +:spawn [*--userscript*] 'args' ['args' ...]+
|
||||
|
||||
Spawn a command in a shell.
|
||||
|
||||
@ -413,6 +402,9 @@ Note the {url} variable which gets replaced by the current URL might be useful h
|
||||
==== positional arguments
|
||||
* +'args'+: The commandline to execute.
|
||||
|
||||
==== optional arguments
|
||||
* +*-u*+, +*--userscript*+: Run the command as an userscript.
|
||||
|
||||
[[stop]]
|
||||
=== stop
|
||||
Stop loading in the current/[count]th tab.
|
||||
|
@ -795,7 +795,7 @@ class CommandDispatcher:
|
||||
tabbed_browser.setUpdatesEnabled(True)
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
def spawn(self, *args):
|
||||
def spawn(self, userscript=False, *args):
|
||||
"""Spawn a command in a shell.
|
||||
|
||||
Note the {url} variable which gets replaced by the current URL might be
|
||||
@ -807,21 +807,30 @@ class CommandDispatcher:
|
||||
don't care about the process anymore as soon as it's spawned.
|
||||
|
||||
Args:
|
||||
userscript: Run the command as an userscript.
|
||||
*args: The commandline to execute.
|
||||
"""
|
||||
log.procs.debug("Executing: {}".format(args))
|
||||
try:
|
||||
subprocess.Popen(args)
|
||||
except OSError as e:
|
||||
raise cmdexc.CommandError("Error while spawning command: "
|
||||
"{}".format(e))
|
||||
log.procs.debug("Executing: {}, userscript={}".format(
|
||||
args, userscript))
|
||||
if userscript:
|
||||
if len(args) > 1:
|
||||
self.run_userscript(args[0], args[1:])
|
||||
else:
|
||||
self.run_userscript(args[0])
|
||||
else:
|
||||
try:
|
||||
subprocess.Popen(args)
|
||||
except OSError as e:
|
||||
raise cmdexc.CommandError("Error while spawning command: "
|
||||
"{}".format(e))
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
def home(self):
|
||||
"""Open main startpage in current tab."""
|
||||
self.openurl(config.get('general', 'startpage')[0])
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||
deprecated='Use :spawn --userscript instead!')
|
||||
def run_userscript(self, cmd, *args: {'nargs': '*'}):
|
||||
"""Run an userscript given as argument.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user