source: trunk/morituri/rip/main.py @ 403

Revision 403, 1.4 KB checked in by thomas, 3 years ago (diff)
Line 
1# -*- Mode: Python -*-
2# vi:si:et:sw=4:sts=4:ts=4
3
4import sys
5
6from morituri.common import log, logcommand
7from morituri.rip import cd, offset, drive, image
8
9def main(argv):
10    c = Rip()
11    try:
12        ret = c.parse(argv)
13    except SystemError, e:
14        sys.stderr.write('rip: error: %s\n' % e.args)
15        return 255
16    except ImportError, e:
17        # FIXME: decide how to handle
18        raise
19        # deps.handleImportError(e)
20        # ret = -1
21
22    if ret is None:
23        return 0
24
25    return ret
26
27class Rip(logcommand.LogCommand):
28    usage = "%prog %command"
29    description = """Rip rips CD's.
30
31Rip gives you a tree of subcommands to work with.
32You can get help on subcommands by using the -h option to the subcommand.
33"""
34
35    subCommandClasses = [cd.CD, drive.Drive, offset.Offset, image.Image, ]
36
37    def addOptions(self):
38        # FIXME: is this the right place ?
39        log.init()
40        from morituri.configure import configure
41        log.debug("morituri", "This is morituri version %s" % configure.version)
42
43        self.parser.add_option('-v', '--version',
44                          action="store_true", dest="version",
45                          help="show version information")
46
47    def handleOptions(self, options):
48        if options.version:
49            from morituri.configure import configure
50            print "rip %s" % configure.version
51            sys.exit(0)
Note: See TracBrowser for help on using the repository browser.