Merge lp:~mvo/click/lp1294659-list-frameworks into lp:click/devel

Proposed by Michael Vogt
Status: Merged
Approved by: Colin Watson
Approved revision: 426
Merged at revision: 439
Proposed branch: lp:~mvo/click/lp1294659-list-frameworks
Merge into: lp:click/devel
Diff against target: 81 lines (+49/-0)
3 files modified
click/commands/__init__.py (+1/-0)
click/commands/framework.py (+42/-0)
doc/manpage.rst (+6/-0)
To merge this branch: bzr merge lp:~mvo/click/lp1294659-list-frameworks
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+219721@code.launchpad.net

Description of the change

This branch adds a command to list the available frameworks.

Its almost too simple so feedback welcome, we might use "click frameworks list" if you prefer a subcommand instead.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

I'd prefer all the .py file names to be importable, to make future test code easier; so if we're going to have "click list-frameworks" then I'd like there to be something in the top-level command machinery that figures out that it needs to do s/-/_/g.

I think I have a slight preference for "click framework list" (singular "framework", by analogy with "click hook"), though. I can imagine other useful subcommands there, for example something to print a single field from an installed framework declaration.

review: Needs Fixing
426. By Michael Vogt

use click framework list instead of click list-frameworks

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your review.I changed the code to use the "click framework list" syntax now.

Revision history for this message
Colin Watson (cjwatson) wrote :

Thanks. I'll fix up the documentation :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'click/commands/__init__.py'
2--- click/commands/__init__.py 2013-10-31 20:17:19 +0000
3+++ click/commands/__init__.py 2014-05-20 07:02:57 +0000
4@@ -28,6 +28,7 @@
5 "info",
6 "install",
7 "list",
8+ "framework",
9 "pkgdir",
10 "register",
11 "unregister",
12
13=== added file 'click/commands/framework.py'
14--- click/commands/framework.py 1970-01-01 00:00:00 +0000
15+++ click/commands/framework.py 2014-05-20 07:02:57 +0000
16@@ -0,0 +1,42 @@
17+# Copyright (C) 2014 Canonical Ltd.
18+# Author: Michael Vogt <mvo@ubuntu.com>
19+
20+# This program is free software: you can redistribute it and/or modify
21+# it under the terms of the GNU General Public License as published by
22+# the Free Software Foundation; version 3 of the License.
23+#
24+# This program is distributed in the hope that it will be useful,
25+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+# GNU General Public License for more details.
28+#
29+# You should have received a copy of the GNU General Public License
30+# along with this program. If not, see <http://www.gnu.org/licenses/>.
31+
32+"""List available frameworks."""
33+
34+from __future__ import print_function
35+
36+from argparse import ArgumentParser
37+
38+from gi.repository import Click
39+
40+
41+def list(parser, args):
42+ for framework in Click.Framework.get_frameworks():
43+ print("%s" % framework.props.name)
44+ return 0
45+
46+
47+def run(argv):
48+ parser = ArgumentParser("click framework")
49+ subparsers = parser.add_subparsers()
50+ list_parser = subparsers.add_parser(
51+ "list",
52+ help="list available frameworks")
53+ list_parser.set_defaults(func=list)
54+ args = parser.parse_args(argv)
55+ if not hasattr(args, "func"):
56+ parser.print_help()
57+ return 1
58+ return args.func(parser, args)
59
60=== modified file 'doc/manpage.rst'
61--- doc/manpage.rst 2014-03-18 11:47:21 +0000
62+++ doc/manpage.rst 2014-05-20 07:02:57 +0000
63@@ -42,6 +42,7 @@
64 click info PATH
65 click install PACKAGE-FILE
66 click list
67+ click list-frameworks
68 click pkgdir {PACKAGE-NAME|PATH}
69 click register PACKAGE-NAME VERSION
70 click unregister PACKAGE-NAME [VERSION]
71@@ -263,6 +264,11 @@
72 permission).
73 --manifest Format output as a JSON array of manifests.
74
75+click list-frameworks
76+---------------------
77+
78+Display a list of available frameworks as one framework per line.
79+
80 click pkgdir {PACKAGE-NAME|PATH}
81 --------------------------------
82

Subscribers

People subscribed via source and target branches

to all changes: