From 09556979d6499a3fac49f809a71ea0e5785272d0 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Oct 08 2014 14:41:03 +0000 Subject: command: not quiet + with outputs files -> print their names Primarily intended as a message suitable for CLI usage. Signed-off-by: Jan Pokorný --- diff --git a/command.py b/command.py index 9d7a866..0bd2e22 100644 --- a/command.py +++ b/command.py @@ -10,6 +10,7 @@ from collections import MutableMapping from itertools import izip_longest from optparse import SUPPRESS_HELP from os import fdopen +from sys import stderr from .command_context import CommandContext from .error import ClufterError, \ @@ -358,7 +359,8 @@ class Command(object): worklist = list(reversed(tailshake(terminal_chain, partitioner=lambda x: not (tuplist(x)) or protodecl(x)))) - unused = {} + maxl = sorted(worklist, key=lambda x: len(x[0].__class__.name))[-1][0] + maxl, unused = len(maxl.__class__.name), {} while worklist: flt, io_decl = worklist.pop() io_decl_use = protodictval(io_decl) @@ -428,6 +430,11 @@ class Command(object): .format(flt.__class__.__name__, io_decl)) # store output somewhere, which even can be useful (use as a lib) passout['passout'] = flt_ctxt['out'](*io_decl) + if not cmd_ctxt['quiet'] and passout is unused: + if io_decl[0] == SimpleFormat.FILE: + print >>stderr, "[{0:{1}}] output file: {2}".format( + flt.__class__.__name__, maxl, passout['passout'] + ) map(lambda f: f.close(), magic_fds.itervalues()) # close "magic" fds return EC.EXIT_SUCCESS # XXX some better decision?