From 78d1e362b8f18f49aabaaf1b415ca62b478043fd Mon Sep 17 00:00:00 2001 From: elig0n Date: Thu, 30 Jul 2020 19:00:20 +0300 Subject: [PATCH] Added --dir,-d flag to :download-open Updated documentation --- doc/help/commands.asciidoc | 4 +++- qutebrowser/browser/downloads.py | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index a5beec12b..49c74d117 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -469,7 +469,7 @@ The index of the download to delete. [[download-open]] === download-open -Syntax: +:download-open ['cmdline']+ +Syntax: +:download-open [*--dir*] ['cmdline']+ Open the last/[count]th download. @@ -480,6 +480,8 @@ If no specific command is given, this will use the system's default application present, the filename is automatically appended to the cmdline. +==== optional arguments +* +*-d*+, +*--dir*+: Open the file's directory instead ==== count The index of the download to open. diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index 39c07472f..1efb3e474 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -1097,7 +1097,8 @@ class DownloadModel(QAbstractListModel): @cmdutils.register(instance='download-model', scope='window', maxsplit=0) @cmdutils.argument('count', value=cmdutils.Value.count) - def download_open(self, cmdline: str = None, count: int = 0) -> None: + @cmdutils.argument('dir', flag='d') + def download_open(self, cmdline: str = None, count: int = 0, dir: bool = False) -> None: """Open the last/[count]th download. If no specific command is given, this will use the system's default @@ -1109,6 +1110,7 @@ class DownloadModel(QAbstractListModel): present, the filename is automatically appended to the cmdline. count: The index of the download to open. + dir: Whether to open the file's directory instead """ try: download = self[count - 1] @@ -1119,7 +1121,10 @@ class DownloadModel(QAbstractListModel): count = len(self) raise cmdutils.CommandError("Download {} is not done!" .format(count)) - download.open_file(cmdline) + if dir: + download.open_file(cmdline, open_dir=True) + else: + download.open_file(cmdline) @cmdutils.register(instance='download-model', scope='window') @cmdutils.argument('count', value=cmdutils.Value.count)