|
12 | 12 | import asyncio
|
13 | 13 |
|
14 | 14 | from subprocess import Popen, DEVNULL, PIPE
|
15 |
| -from threading import Thread |
16 |
| -from time import sleep |
17 | 15 |
|
18 | 16 | from . import _mixin as mixin
|
19 | 17 | from .. import CmdError, CommandMeta
|
@@ -183,18 +181,21 @@ class FOpenCmdbase(metaclass=CommandMeta):
|
183 | 181 | 'fileopen "that torrent" *.mkv mpv'
|
184 | 182 | 'fileopen "that torrent" *.mkv mpv --fullscreen',)
|
185 | 183 | argspecs = (
|
| 184 | + {'names': ('--quiet', '-q'), |
| 185 | + 'description': 'Suppress stdout from the external command. Pass twice to also suppress stderr', |
| 186 | + 'action': 'count', 'default': 0}, |
186 | 187 | make_X_FILTER_spec('TORRENT', or_focused=True, nargs='?'),
|
187 | 188 | make_X_FILTER_spec('FILE', or_focused=True, nargs='?'),
|
188 |
| - {"names": ('COMMAND',), |
189 |
| - 'description': "Command to use to open files. Default: xdg-open", |
| 189 | + {'names': ('COMMAND',), |
| 190 | + 'description': 'Command to use to open files. Default: xdg-open', |
190 | 191 | 'nargs': '?'
|
191 | 192 | },
|
192 |
| - {"names": ('OPTS',), |
| 193 | + {'names': ('OPTS',), |
193 | 194 | 'description': "Options for the external command.",
|
194 | 195 | 'nargs': 'REMAINDER'
|
195 | 196 | },
|
196 | 197 | )
|
197 |
| - async def run(self, TORRENT_FILTER, FILE_FILTER, COMMAND, OPTS): |
| 198 | + async def run(self, quiet, TORRENT_FILTER, FILE_FILTER, COMMAND, OPTS): |
198 | 199 | default_command = 'xdg-open'
|
199 | 200 | if COMMAND is None:
|
200 | 201 | command = default_command
|
@@ -244,7 +245,11 @@ def closepipes(proc):
|
244 | 245 |
|
245 | 246 | # TODO separate options for stdout/stderr
|
246 | 247 | stdoutlogger = lambda s: self.info(command + ": " + s)
|
| 248 | + if quiet >= 1: |
| 249 | + stdoutlogger = lambda s: None |
247 | 250 | stderrlogger = lambda s: self.error(command + ": " + s)
|
| 251 | + if quiet >= 2: |
| 252 | + stderrlogger = lambda s: None |
248 | 253 | loop = asyncio.get_running_loop()
|
249 | 254 | try:
|
250 | 255 | if command == default_command:
|
|
0 commit comments