-
Notifications
You must be signed in to change notification settings - Fork 0
/
ptr
executable file
·77 lines (68 loc) · 2.48 KB
/
ptr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python
#
# Copyright (c) 2002 Gustavo Niemeyer <[email protected]>
#
# This file is part of patcher.
#
# pybot is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# pybot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pybot; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
from patcher import Error
from patcher.command import *
import sys
AUTHOR = "Gustavo Niemeyer <[email protected]>"
VERSION = "0.7"
HELP = """\
Usage: ptr COMMAND [COMMAND ARGUMENTS]
Available commands:
start Create patcher structures
stop Remove patcher structures
diff Run diff between working copies and pristine versions
status Check entries status
revert Revert working copy to pristine version
ignore Ignore given entries when doing certain operations
unignore Revert effect of ignore command
add Add given entries to patcher control
remove Remove given entries from patcher control
Run "ptr COMMAND --help" for more information.
Written by Gustavo Niemeyer <[email protected]>.
"""
def parse_options():
parser = OptionParser(help=HELP, version="patcher "+VERSION)
parser.disable_interspersed_args()
parser.add_option("--debug", action="store_true")
opts, args = parser.parse_args()
opts.args = args
if len(args) < 1:
sys.stderr.write(HELP)
sys.exit(1)
opts.command = args[0]
opts.args = args
return opts
def dispatch_command(command, args, debug=0):
sys.argv = args
try:
patcher_module = __import__("patcher.commands."+command)
commands_module = getattr(patcher_module, "commands")
command_module = getattr(commands_module, command)
except (ImportError, AttributeError):
if debug:
import traceback
traceback.print_exc()
sys.exit(1)
raise Error, "invalid command '%s'" % command
command_module.main()
if __name__ == "__main__":
do_command(parse_options, dispatch_command)
# vim:et:ts=4:sw=4