Add -s argument to set temporary options.
This commit is contained in:
parent
5ed592a447
commit
7615e20091
@ -39,7 +39,7 @@ from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QTimer, QUrl,
|
||||
import qutebrowser
|
||||
import qutebrowser.resources # pylint: disable=unused-import
|
||||
from qutebrowser.commands import cmdutils, runners
|
||||
from qutebrowser.config import style, config, websettings
|
||||
from qutebrowser.config import style, config, websettings, configexc
|
||||
from qutebrowser.browser import quickmarks, cookies, cache, adblock, history
|
||||
from qutebrowser.browser.network import qutescheme, proxy
|
||||
from qutebrowser.mainwindow import mainwindow
|
||||
@ -136,7 +136,7 @@ class Application(QApplication):
|
||||
"Error while initializing: {}".format(e))
|
||||
msgbox.exec_()
|
||||
sys.exit(1)
|
||||
QTimer.singleShot(0, self._open_pages)
|
||||
QTimer.singleShot(0, self._process_args)
|
||||
|
||||
log.init.debug("Initializing eventfilter...")
|
||||
self._event_filter = modeman.EventFilter(self)
|
||||
@ -252,14 +252,21 @@ class Application(QApplication):
|
||||
else:
|
||||
earlyinit.init_faulthandler(self._crashlogfile)
|
||||
|
||||
def _open_pages(self):
|
||||
def _process_args(self):
|
||||
"""Open startpage etc. and process commandline args."""
|
||||
self.process_args(self._args.command)
|
||||
config_obj = objreg.get('config')
|
||||
for sect, opt, val in self._args.temp_settings:
|
||||
try:
|
||||
config_obj.set('temp', sect, opt, val)
|
||||
except (configexc.Error, configparser.Error) as e:
|
||||
message.error('current', "set: {} - {}".format(
|
||||
e.__class__.__name__, e))
|
||||
self.process_pos_args(self._args.command)
|
||||
self._open_startpage()
|
||||
self._open_quickstart()
|
||||
|
||||
def _get_window(self, via_ipc, force_window=False, force_tab=False):
|
||||
"""Helper function for process_args to get a window id.
|
||||
"""Helper function for process_pos_args to get a window id.
|
||||
|
||||
Args:
|
||||
via_ipc: Whether the request was made via IPC.
|
||||
@ -299,8 +306,8 @@ class Application(QApplication):
|
||||
self.alert(window_to_raise)
|
||||
return win_id
|
||||
|
||||
def process_args(self, args, via_ipc=False, cwd=None):
|
||||
"""Process commandline args.
|
||||
def process_pos_args(self, args, via_ipc=False, cwd=None):
|
||||
"""Process positional commandline args.
|
||||
|
||||
URLs to open have no prefix, commands to execute begin with a colon.
|
||||
|
||||
|
@ -158,7 +158,7 @@ class IPCServer(QObject):
|
||||
return
|
||||
cwd = json_data.get('cwd', None)
|
||||
app = objreg.get('app')
|
||||
app.process_args(args, via_ipc=True, cwd=cwd)
|
||||
app.process_pos_args(args, via_ipc=True, cwd=cwd)
|
||||
|
||||
@pyqtSlot()
|
||||
def on_timeout(self):
|
||||
|
@ -49,6 +49,11 @@ def get_argparser():
|
||||
"for no config storage)")
|
||||
parser.add_argument('-V', '--version', help="Show version and quit.",
|
||||
action='store_true')
|
||||
parser.add_argument('-s', '--set', help="Set a temporary setting for "
|
||||
"this session", nargs=3, action='append',
|
||||
dest='temp_settings', default=[],
|
||||
metavar=('SECTION', 'OPTION', 'VALUE'))
|
||||
|
||||
debug = parser.add_argument_group('debug arguments')
|
||||
debug.add_argument('-l', '--loglevel', dest='loglevel',
|
||||
help="Set loglevel", default='info')
|
||||
|
Loading…
Reference in New Issue
Block a user