From 8cf0af004fd8f3c2e9f7e8e23a1c2bc6107ebe86 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 7 Oct 2015 23:13:17 +0200 Subject: [PATCH] Deprecate :download [url] [dest], add --dest param :download --dest [dest] [url] is the new syntax. --- doc/help/commands.asciidoc | 9 +++++++-- qutebrowser/browser/commands.py | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index f54bd6010..dcc90af65 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -146,13 +146,18 @@ Close the current window. [[download]] === download -Syntax: +:download ['url'] ['dest']+ +Syntax: +:download [*--dest* 'DEST'] ['url'] ['dest-old']+ Download a given URL, or current page if no URL given. +The form `:download [url] [dest]` is deprecated, use `:download --dest [dest] [url]` instead. + ==== positional arguments * +'url'+: The URL to download. If not given, download the current page. -* +'dest'+: The file path to write the download to, or not given to ask. +* +'dest-old'+: (deprecated) Same as dest. + +==== optional arguments +* +*-d*+, +*--dest*+: The file path to write the download to, or not given to ask. [[download-cancel]] === download-cancel diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index a2cfff718..633285727 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1140,13 +1140,25 @@ class CommandDispatcher: cur.inspector.show() @cmdutils.register(instance='command-dispatcher', scope='window') - def download(self, url=None, dest=None): + def download(self, url=None, dest_old=None, *, dest=None): """Download a given URL, or current page if no URL given. + The form `:download [url] [dest]` is deprecated, use `:download --dest + [dest] [url]` instead. + Args: url: The URL to download. If not given, download the current page. + dest_old: (deprecated) Same as dest. dest: The file path to write the download to, or None to ask. """ + if dest_old is not None: + message.warning('current', ":download [url] [dest] is deprecated -" + " use download --dest [dest] [url]") + if dest is not None: + raise cmdexc.CommandError("Can't give two destinations for the" + " download.") + dest = dest_old + download_manager = objreg.get('download-manager', scope='window', window=self._win_id) if url: @@ -1155,7 +1167,7 @@ class CommandDispatcher: download_manager.get(url, filename=dest) else: page = self._current_widget().page() - download_manager.get(self._current_url(), page=page) + download_manager.get(self._current_url(), page=page, filename=dest) @cmdutils.register(instance='command-dispatcher', scope='window') def download_whole(self, dest=None):