Commits

kunstmusik  committed 60cb92d

experimenting with Command object and building usage message

  • Participants
  • Parent commits e609608

Comments (0)

Files changed (1)

+#!/usr/bin/env python
+
+VERSION = "1.0 Alpha"
+
 
 class Command(object):
-    def __init__(self):
-        pass
+    def __init__(self, commandName, description, processFunction):
+        self.commandName = commandName
+        self.description = description
+        self.processFunction = processFunction
     
-    def help(self):
-        """Return Help String"""
-        pass
-
-    def process(self):
+    def process(self, args):
         """Function for Command to do work"""
-        pass
+        return self.processFunction(args)
+    
+def dummyFunc(args):
+    print "Command not implemented"
+    return True
+    
+commands = [Command("install", "Installs a list of packages.", dummyFunc ),
+            Command("update", "Update list of known packages.", dummyFunc),
+            Command("list", "List packages matching a search string.", dummyFunc),
+            Command("info", "Display detailed information about a particular package.", dummyFunc),
+            Command("init", "Create a default .cspm file in the current directory.", dummyFunc)
+
+             ]    
+
+
+def usage():
+    message = """Csound Package Manager - version %s
     
+Usage: cspm.py COMMAND [flags]
+       
+Commands:
+"""%VERSION
+
+    for i in commands:
+        message += "  %-14s%s\n"%(i.commandName, i.description)
         
+    return message
+
+    
 if __name__ == '__main__':
-    print "Csound Package Manager"
+    print usage()
+