1
from __future__ import with_statement
2
# -*- coding: utf-8 -*-
5
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
6
__docformat__ = 'restructuredtext en'
9
Command line interface to run pdf manipulation commands.
14
from calibre.utils.config import OptionParser
15
from calibre.utils.logging import Log
16
from calibre.constants import preferred_encoding
17
from calibre.ebooks.pdf.manipulate import crop, decrypt, encrypt, \
18
info, merge, reverse, rotate, split
31
USAGE = '%prog ' + _('''command ...
33
command can be one of the following:
36
Use %prog command --help to get more information about a specific command
39
''').replace('%%commands', string.join(sorted(COMMANDS.keys()), ', '))
41
def print_help(parser, log):
42
help = parser.format_help().encode(preferred_encoding, 'replace')
46
return OptionParser(usage=USAGE)
48
def main(args=sys.argv):
50
parser = option_parser()
53
print 'Error: No command sepecified.\n'
54
print_help(parser, log)
57
command = args[1].lower().strip()
59
if command in COMMANDS.keys():
61
return COMMANDS[command].main(args, command)
63
parser.parse_args(args)
64
print 'Unknown command %s.\n' % command
65
print_help(parser, log)
68
# We should never get here.
71
if __name__ == '__main__':