3 from optparse
import OptionParser
6 from zeroinstall
.zerostore
import cli
8 parser
= OptionParser(usage
="usage: %prog " +
9 '\n %prog '.join([c
.__doc
__ for c
in cli
.commands
]))
10 parser
.add_option("-v", "--verbose", help="more verbose output", action
='count')
11 parser
.add_option("-V", "--version", help="display version information", action
='store_true')
12 parser
.disable_interspersed_args()
14 (options
, args
) = parser
.parse_args()
17 logger
= logging
.getLogger()
18 if options
.verbose
== 1:
19 logger
.setLevel(logging
.INFO
)
21 logger
.setLevel(logging
.DEBUG
)
22 hdlr
= logging
.StreamHandler()
23 fmt
= logging
.Formatter("%(levelname)s:%(message)s")
24 hdlr
.setFormatter(fmt
)
25 logger
.addHandler(hdlr
)
29 print "0store (zero-install) " + zeroinstall
.version
30 print "Copyright (C) 2005 Thomas Leonard"
31 print "This program comes with ABSOLUTELY NO WARRANTY,"
32 print "to the extent permitted by law."
33 print "You may redistribute copies of this program"
34 print "under the terms of the GNU General Public License."
35 print "For more information about these matters, see the file named COPYING."
42 pattern
= args
[0].lower()
43 matches
= [c
for c
in cli
.commands
if c
.__name
__.startswith(pattern
)]
48 print >>sys
.stderr
, "What do you mean by '%s'?" % pattern
55 except KeyboardInterrupt, ex
:
56 print >>sys
.stderr
, "Interrupted"
59 print >>sys
.stderr
, str(ex
)
62 print >>sys
.stderr
, str(ex
)