]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
working on cmd line
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 25 Apr 2010 13:32:53 +0000 (09:32 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 25 Apr 2010 13:32:53 +0000 (09:32 -0400)
alembic/command.py
alembic/options.py
scripts/alembic [changed mode: 0644->0755]

index ab40617dd9e0b7ee9ddf82a7d774c00d50753fc4..8fdc9a45d80c6c30f5e37fefa56b1156d6a60846 100644 (file)
@@ -1,9 +1,19 @@
-from alembic.script import Script
+from alembic.script import ScriptDirectory
+from alembic import options
 
-def main(options, command):
-    raise NotImplementedError("yeah yeah nothing here yet")
+def main(argv=None):
 
+    parser = options.get_option_parser()
 
+    opts, args = parser.parse_args(argv[1:])
+    if len(args) < 1:
+        parser.error("no command specified") # Will exit
+
+    print opts.config
+
+def list_templates(options):
+    """List available templates"""
+    
 def init(options):
     """Initialize a new scripts directory."""
     
index afc26c247efbe77b717ee7934fc4b95ef4bceaee..1749400bfad5d3933af71841941b4bf53a3015b7 100644 (file)
@@ -1,6 +1,36 @@
+from optparse import OptionParser
+import ConfigParser
+import textwrap
 
 def get_option_parser():
-    parser = OptionParser("usage: %prog [options] <command>")
+    # TODO: 
+    # OK, what's the super option parser library that 
+    # allows <command> plus command-specfic sub-options ?
+    
+    # TODO: pull the commands from command.py directly here
+    parser = OptionParser(
+                "usage: %prog [options] <command>\n\n"
+                "Available Commands:\n"
+                "  list-templates\n"
+                "  init\n"
+                "  revision\n"
+                "  upgrade\n"
+                "  revert\n"
+                "  history\n"
+                "  splice\n"
+                "  branches"
+                )
+    parser.add_option("-c", "--config", 
+                        type="string", 
+                        default="alembic.ini", 
+                        help="Alternate config file")
+    parser.add_option("-t", "--template",
+                        type="string",
+                        help="Setup template for use with 'init'")
+    parser.add_option("-r", "--rev",
+                        type="string",
+                        help="Revsion identifier for usage with 'revert'"
+    )
     return parser
     
 class Options(object):
old mode 100644 (file)
new mode 100755 (executable)
index df453e2..65d7e02
@@ -1,20 +1,8 @@
 #!/usr/bin/env python
 
-import alembic
+from alembic import command
 import sys
-from optparse import OptionParser
-
-def main(argv=None):
-    parser = alembic.options.get_option_parser()
-
-    opts, args = parser.parse_args(argv[1:])
-    if len(args) < 1:
-        parser.error("no command specified") # Will exit
-
-    command = args[0]
-
-    alembic.main(options, file_config, command)
 
 if __name__ == "__main__":
-    main(sys.argv)
+    command.main(sys.argv)