Add a :version command

This commit is contained in:
Florian Bruhin 2017-10-04 06:22:51 +02:00
parent feaccb3083
commit 8c660d1bf4
4 changed files with 30 additions and 1 deletions

View File

@ -67,6 +67,7 @@ Added
- `:config-clear` to remove all configured options
- `:config-source` to (re-)read a `config.py` file
- `:config-edit` to open the `config.py` file in an editor
- New `:version` command which opens `qute://version`.
Changed
~~~~~~~

View File

@ -91,6 +91,7 @@ It is possible to run or bind multiple commands by separating them with `;;`.
|<<tab-prev,tab-prev>>|Switch to the previous tab, or switch [count] tabs back.
|<<unbind,unbind>>|Unbind a keychain.
|<<undo,undo>>|Re-open a closed tab.
|<<version,version>>|Show version information.
|<<view-source,view-source>>|Show the source of the current page in a new tab.
|<<window-only,window-only>>|Close all windows except for the current one.
|<<yank,yank>>|Yank something to the clipboard or primary selection.
@ -1015,6 +1016,10 @@ Unbind a keychain.
=== undo
Re-open a closed tab.
[[version]]
=== version
Show version information.
[[view-source]]
=== view-source
Show the source of the current page in a new tab.

View File

@ -342,3 +342,12 @@ def window_only(current_win_id):
def nop():
"""Do nothing."""
return
@cmdutils.register()
@cmdutils.argument('win_id', win_id=True)
def version(win_id):
"""Show version information."""
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
tabbed_browser.openurl(QUrl('qute://version'), newtab=True)

View File

@ -25,10 +25,11 @@ import signal
import time
import pytest
from PyQt5.QtCore import QUrl
from qutebrowser.misc import utilcmds
from qutebrowser.commands import cmdexc
from qutebrowser.utils import utils
from qutebrowser.utils import utils, objreg
@contextlib.contextmanager
@ -142,3 +143,16 @@ def test_window_only(mocker, monkeypatch):
assert not test_windows[0].closed
assert not test_windows[1].closed
assert test_windows[2].closed
@pytest.fixture
def tabbed_browser(stubs, win_registry):
tb = stubs.TabbedBrowserStub()
objreg.register('tabbed-browser', tb, scope='window', window=0)
yield tb
objreg.delete('tabbed-browser', scope='window', window=0)
def test_version(tabbed_browser):
utilcmds.version(win_id=0)
assert tabbed_browser.opened_url == QUrl('qute://version')