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.
|
|<<repeat,repeat>>|Repeat a given command.
|
||||||
|<<report,report>>|Report a bug in qutebrowser.
|
|<<report,report>>|Report a bug in qutebrowser.
|
||||||
|<<restart,restart>>|Restart qutebrowser while keeping existing tabs open.
|
|<<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.
|
|<<save,save>>|Save the config file.
|
||||||
|<<search,search>>|Search for a text on the current page.
|
|<<search,search>>|Search for a text on the current page.
|
||||||
|<<set,set>>|Set an option.
|
|<<set,set>>|Set an option.
|
||||||
@ -351,16 +350,6 @@ Report a bug in qutebrowser.
|
|||||||
=== restart
|
=== restart
|
||||||
Restart qutebrowser while keeping existing tabs open.
|
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
|
=== save
|
||||||
Save the config file.
|
Save the config file.
|
||||||
@ -404,7 +393,7 @@ Preset the statusbar to some text.
|
|||||||
|
|
||||||
[[spawn]]
|
[[spawn]]
|
||||||
=== spawn
|
=== spawn
|
||||||
Syntax: +:spawn 'args' ['args' ...]+
|
Syntax: +:spawn [*--userscript*] 'args' ['args' ...]+
|
||||||
|
|
||||||
Spawn a command in a shell.
|
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
|
==== positional arguments
|
||||||
* +'args'+: The commandline to execute.
|
* +'args'+: The commandline to execute.
|
||||||
|
|
||||||
|
==== optional arguments
|
||||||
|
* +*-u*+, +*--userscript*+: Run the command as an userscript.
|
||||||
|
|
||||||
[[stop]]
|
[[stop]]
|
||||||
=== stop
|
=== stop
|
||||||
Stop loading in the current/[count]th tab.
|
Stop loading in the current/[count]th tab.
|
||||||
|
@ -795,7 +795,7 @@ class CommandDispatcher:
|
|||||||
tabbed_browser.setUpdatesEnabled(True)
|
tabbed_browser.setUpdatesEnabled(True)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
def spawn(self, *args):
|
def spawn(self, userscript=False, *args):
|
||||||
"""Spawn a command in a shell.
|
"""Spawn a command in a shell.
|
||||||
|
|
||||||
Note the {url} variable which gets replaced by the current URL might be
|
Note the {url} variable which gets replaced by the current URL might be
|
||||||
@ -807,9 +807,17 @@ class CommandDispatcher:
|
|||||||
don't care about the process anymore as soon as it's spawned.
|
don't care about the process anymore as soon as it's spawned.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
userscript: Run the command as an userscript.
|
||||||
*args: The commandline to execute.
|
*args: The commandline to execute.
|
||||||
"""
|
"""
|
||||||
log.procs.debug("Executing: {}".format(args))
|
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:
|
try:
|
||||||
subprocess.Popen(args)
|
subprocess.Popen(args)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
@ -821,7 +829,8 @@ class CommandDispatcher:
|
|||||||
"""Open main startpage in current tab."""
|
"""Open main startpage in current tab."""
|
||||||
self.openurl(config.get('general', 'startpage')[0])
|
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': '*'}):
|
def run_userscript(self, cmd, *args: {'nargs': '*'}):
|
||||||
"""Run an userscript given as argument.
|
"""Run an userscript given as argument.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user