#
# src - simple revision control.
#
-import sys
+import sys, os
version = 0.1
+def complain(msg):
+ sys.stderr.write("src: " + msg + "\n")
+
def help(*args):
+ "Summarize src commands, or (with argument) show help for a single command."
print"""
src help [command]
Displays help for commands.
Export one or more projects as a git fast-import stream.
"""
+def init(*args):
+ "Create a .src directory if none already exists."
+ if not os.path.exists(".src"):
+ try:
+ os.mkdir(".src")
+ except OSError:
+ complain(".src/ creation failed, check directory permissions.")
+ elif os.path.isdir(".src"):
+ complain(".src/ already exists.")
+ else:
+ complain(".src/ exists but is not a directory.")
+
if __name__ == "__main__":
command = sys.argv[1:]
if not command:
help()
else:
- eval(command[0])(*command[1:])
+ try:
+ eval(command[0])(*command[1:])
+ except NameError:
+ sys.stderr.write("src: no such command as '%s'. Try 'src help'\n" \
+ % command[0])