7 output
= fd
.readlines()
13 class YapError(Exception):
14 def __init__(self
, msg
):
20 def takes_options(options
):
22 func
.options
= options
27 def cmd_clone(self
, url
, directory
=""):
28 # XXX: implement in terms of init + remote add + fetch
29 os
.system("git clone '%s' %s" % (url
, directory
))
34 def cmd_add(self
, file):
35 if not os
.access(file, os
.R_OK
):
36 raise YapError("No such file: %s" % file)
37 x
= get_output("git ls-files '%s'" % file)
39 raise YapError("File '%s' already in repository" % file)
40 os
.system("git update-index --add '%s'" % file)
42 def cmd_version(self
):
43 print "Yap version 0.1"
46 print >> sys
.stderr
, "usage: %s <command>" % sys
.argv
[0]
47 print >> sys
.stderr
, " valid commands: version"
57 debug
= os
.getenv('YAP_DEBUG')
60 meth
= self
.__getattribute
__("cmd_"+command
)
62 if "option" in meth
.__dict
__:
63 flags
, args
= getopt
.getopt(args
, meth
.options
)
69 except (TypeError, getopt
.GetoptError
), e
:
72 print "%s %s %s" % (sys
.argv
[0], command
, meth
.__doc
__)
74 print >> sys
.stderr
, e
76 except AttributeError, e
: