1 Return-Path: <wking@tremily.us>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 19EE1431FC0
\r
6 for <notmuch@notmuchmail.org>; Fri, 3 Oct 2014 11:21:15 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5
\r
13 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
14 RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id YE-tOzpSDU84 for <notmuch@notmuchmail.org>;
\r
18 Fri, 3 Oct 2014 11:21:07 -0700 (PDT)
\r
19 Received: from resqmta-po-07v.sys.comcast.net (resqmta-po-07v.sys.comcast.net
\r
21 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
22 (No client certificate requested)
\r
23 by olra.theworths.org (Postfix) with ESMTPS id BBFB8431FB6
\r
24 for <notmuch@notmuchmail.org>; Fri, 3 Oct 2014 11:21:07 -0700 (PDT)
\r
25 Received: from resomta-po-19v.sys.comcast.net ([96.114.154.243])
\r
26 by resqmta-po-07v.sys.comcast.net with comcast
\r
27 id yiLt1o0055FMDhs01iM7D0; Fri, 03 Oct 2014 18:21:07 +0000
\r
28 Received: from odin.tremily.us ([24.18.63.50])
\r
29 by resomta-po-19v.sys.comcast.net with comcast
\r
30 id yiM51o00E152l3L01iM517; Fri, 03 Oct 2014 18:21:06 +0000
\r
31 Received: by odin.tremily.us (Postfix, from userid 1000)
\r
32 id 2699413EA33C; Fri, 3 Oct 2014 11:21:05 -0700 (PDT)
\r
33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;
\r
34 t=1412360465; bh=YDCxxJ0z1/HH/7VyFCX5nYITv+PceEvVcAIWv6EhQYI=;
\r
35 h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To:
\r
37 b=kY3LsZURnKTY2cLjcboWsEE8BScVKgNgYPsAdI6ElwaiOjhZC9wwBS+PYk4cRLj5T
\r
38 Mxt2OY2d5NJ0aMkbtXJVz7vIuBYR0Kk4uXy59SKVZfHUUqL8LTQQt9jnK5fpM1oRjW
\r
39 ndNg+JAWaiY2EaNBrwHDW3UwKooSHIt3PPqqjSZo=
\r
40 From: "W. Trevor King" <wking@tremily.us>
\r
41 To: notmuch@notmuchmail.org
\r
42 Subject: [PATCH v6 2/2] nmbug: Add a 'help' command for folks who don't like
\r
44 Date: Fri, 3 Oct 2014 11:20:58 -0700
\r
46 <0a4f023f734b5c59ff3b3577961f679d141c3c74.1412359989.git.wking@tremily.us>
\r
47 X-Mailer: git-send-email 2.0.4
\r
48 In-Reply-To: <cover.1412359989.git.wking@tremily.us>
\r
49 References: <cover.1412359989.git.wking@tremily.us>
\r
50 In-Reply-To: <cover.1412359989.git.wking@tremily.us>
\r
51 References: <cover.1412359989.git.wking@tremily.us>
\r
52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;
\r
53 s=q20140121; t=1412360467;
\r
54 bh=8rEqzVyY3jed6cjDeAUf2BedGIrbtJReNs8jlFb+B2E=;
\r
55 h=Received:Received:Received:From:To:Subject:Date:Message-Id;
\r
56 b=VUR9gWN6VH6BZ85N7dYxe+ZLD5MZAhn1rPlkHC0F9l+qVWIvZC3WUWfPuXS7fHepd
\r
57 qHXgzi7V2Vb2sADFNKGrtTzGDvOZrxxlPUjukqGQtJLKSGcJHaGWEu+JN3hpqhD92L
\r
58 mKx5Gp8lcVscGhxaRyzRpqcc4UP/ruNaUXxzbRxHOZWRrW+wQTMc4FM3UvU/23Cdrf
\r
59 RxzaHiuI4hNLp8Toh+iYkUXlIpnIfyKHXDLvzgs9CVGEKLB1NJJF2jSqwPemarmj/n
\r
60 yTw7ue1sBiRt+beQtiU9N2qA+oxDlvZEB9YV5VTlkrNmBo/Rb8g7QQAcWOKHyz91Vv
\r
62 Cc: Tomi Ollila <tomi.ollila@iki.fi>, David Bremner <bremner@debian.org>
\r
63 X-BeenThere: notmuch@notmuchmail.org
\r
64 X-Mailman-Version: 2.1.13
\r
66 List-Id: "Use and development of the notmuch mail system."
\r
67 <notmuch.notmuchmail.org>
\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
71 List-Post: <mailto:notmuch@notmuchmail.org>
\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
75 X-List-Received-Date: Fri, 03 Oct 2014 18:21:15 -0000
\r
77 The 'if args.func == help' block at the end avoids:
\r
79 AttributeError: 'functools.partial' object has no attribute '__code__'
\r
81 devel/nmbug/nmbug | 31 ++++++++++++++++++++++++++++++-
\r
82 1 file changed, 30 insertions(+), 1 deletion(-)
\r
84 diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
\r
85 index 9402ead..932ec12 100755
\r
86 --- a/devel/nmbug/nmbug
\r
87 +++ b/devel/nmbug/nmbug
\r
88 @@ -32,6 +32,7 @@ from __future__ import unicode_literals
\r
90 import codecs as _codecs
\r
91 import collections as _collections
\r
92 +import functools as _functools
\r
93 import inspect as _inspect
\r
94 import locale as _locale
\r
95 import logging as _logging
\r
96 @@ -677,6 +678,24 @@ def _unpack_diff_lines(stream):
\r
100 +def _help(parser, command=None):
\r
102 + Show help for an nmbug command.
\r
104 + Because some folks prefer:
\r
106 + $ nmbug help COMMAND
\r
110 + $ nmbug COMMAND --help
\r
113 + parser.parse_args([command, '--help'])
\r
115 + parser.parse_args(['--help'])
\r
118 if __name__ == '__main__':
\r
121 @@ -692,6 +711,8 @@ if __name__ == '__main__':
\r
122 help='Log verbosity. Defaults to {!r}.'.format(
\r
123 _logging.getLevelName(_LOG.level).lower()))
\r
125 + help = _functools.partial(_help, parser=parser)
\r
126 + help.__doc__ = _help.__doc__
\r
127 subparsers = parser.add_subparsers(
\r
130 @@ -703,6 +724,7 @@ if __name__ == '__main__':
\r
138 @@ -746,6 +768,10 @@ if __name__ == '__main__':
\r
139 'Override the default configured in branch.<name>.remote '
\r
140 'to fetch from a particular remote repository (e.g. '
\r
142 + elif command == 'help':
\r
143 + subparser.add_argument(
\r
144 + 'command', metavar='COMMAND', nargs='?',
\r
145 + help='The command to show help for.')
\r
146 elif command == 'log':
\r
147 subparser.add_argument(
\r
148 'args', metavar='ARG', nargs='*',
\r
149 @@ -796,7 +822,10 @@ if __name__ == '__main__':
\r
150 parser.print_usage()
\r
153 - (arg_names, varargs, varkw) = _inspect.getargs(args.func.__code__)
\r
154 + if args.func == help:
\r
155 + arg_names = ['command']
\r
157 + (arg_names, varargs, varkw) = _inspect.getargs(args.func.__code__)
\r
158 kwargs = {key: getattr(args, key) for key in arg_names if key in args}
\r
160 args.func(**kwargs)
\r