karenc / db-migrator

GNU Affero General Public License v3.0
4 stars 5 forks source link

Add option `--context` to dbmigrator in order to load entry points #7

Closed karenc closed 8 years ago

karenc commented 8 years ago

If context is not defined, the current working directory name is used.

Close #6

mmulich commented 8 years ago

Why make context optional? From what I can tell, if I'm in my home directory, then the context becomes 'pumazi'. This will inevitably lead to missing migrations directory warning and possible confusion on my part.

mmulich commented 8 years ago

Printing a message that we are using CWD directory name as the context should be sufficient though.

karenc commented 8 years ago
diff --git a/dbmigrator/cli.py b/dbmigrator/cli.py
index afb73c0..643c181 100644
--- a/dbmigrator/cli.py
+++ b/dbmigrator/cli.py
@@ -47,7 +47,10 @@ def main(argv=sys.argv[1:]):
             ], args)

     if not args.get('context'):
-        args['context'] = os.path.split(os.path.abspath(os.path.curdir))[-1]
+        args['context'] = os.path.basename(os.path.abspath(os.path.curdir))
+        print('context undefined, using current directory name "{}"'
+              .format(args['context']),
+              file=sys.stderr)
     utils.get_settings_from_entry_points(args, args['context'])

     for name, value in DEFAULTS.items():
mmulich commented 8 years ago

Yeah, that change looks good. :+1: