
import argparse
import os
import sys

from . import commands, utils


DEFAULTS = {
    'migrations_directory': 'migrations',
    }

DEFAULT_CONFIG_PATH = 'development.ini'


def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(description='DB Migrator')

    parser.add_argument('--migrations-directory')

    parser.add_argument('--config', default=DEFAULT_CONFIG_PATH)

    parser.add_argument('--db-connection-string',
                        help='a psycopg2 db connection string')

    subparsers = parser.add_subparsers(help='commands')
    commands.load_cli(subparsers)

    args = parser.parse_args(argv)
    args = vars(args)

    if os.path.exists(args['config']):
        utils.get_settings_from_config(args['config'], [
            'migrations-directory',
            'db-connection-string',
            ], args)
    utils.get_settings_from_entry_points(args)

    for name, value in DEFAULTS.items():
        if not args.get(name):
            args[name] = value

    if 'cmmd' not in args:
        parser.print_help()
        return parser.error('command missing')

    args['migrations_directory'] = os.path.relpath(
        args['migrations_directory'])

    return args['cmmd'](**args)


import argparse
import os
import sys

from . import commands, utils


DEFAULTS = {
    }


def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(description='DB Migrator')

    parser.add_argument('--migrations-directory')

    parser.add_argument('--config')

    parser.add_argument('--db-connection-string',
                        help='a psycopg2 db connection string')

    subparsers = parser.add_subparsers(help='commands')
    commands.load_cli(subparsers)

    args = parser.parse_args(argv)
    args = vars(args)

    if os.path.exists(args['config']):
        utils.get_settings_from_config(args['config'], [
            'migrations-directory',
            'db-connection-string',
            ], args)
    utils.get_settings_from_entry_points(args)

    for name, value in DEFAULTS.items():
        if not args.get(name):
            args[name] = value

    if 'cmmd' not in args:
        parser.print_help()
        return parser.error('command missing')

    args['migrations_directory'] = os.path.relpath(
        args['migrations_directory'])

    return args['cmmd'](**args)

Remove default config path (development.ini)
Remove default config path (development.ini)

Towards #1

  
  import argparse
  import os
  import sys
  
  from . import commands, utils
  
  
  DEFAULTS = {
-     'migrations_directory': 'migrations',
      }
- 
- DEFAULT_CONFIG_PATH = 'development.ini'
  
  
  def main(argv=sys.argv[1:]):
      parser = argparse.ArgumentParser(description='DB Migrator')
  
      parser.add_argument('--migrations-directory')
  
-     parser.add_argument('--config', default=DEFAULT_CONFIG_PATH)
+     parser.add_argument('--config')
  
      parser.add_argument('--db-connection-string',
                          help='a psycopg2 db connection string')
  
      subparsers = parser.add_subparsers(help='commands')
      commands.load_cli(subparsers)
  
      args = parser.parse_args(argv)
      args = vars(args)
  
      if os.path.exists(args['config']):
          utils.get_settings_from_config(args['config'], [
              'migrations-directory',
              'db-connection-string',
              ], args)
      utils.get_settings_from_entry_points(args)
  
      for name, value in DEFAULTS.items():
          if not args.get(name):
              args[name] = value
  
      if 'cmmd' not in args:
          parser.print_help()
          return parser.error('command missing')
  
      args['migrations_directory'] = os.path.relpath(
          args['migrations_directory'])
  
      return args['cmmd'](**args)
  
Remove default config path (development.ini)
## Code Before:

import argparse
import os
import sys

from . import commands, utils


DEFAULTS = {
    'migrations_directory': 'migrations',
    }

DEFAULT_CONFIG_PATH = 'development.ini'


def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(description='DB Migrator')

    parser.add_argument('--migrations-directory')

    parser.add_argument('--config', default=DEFAULT_CONFIG_PATH)

    parser.add_argument('--db-connection-string',
                        help='a psycopg2 db connection string')

    subparsers = parser.add_subparsers(help='commands')
    commands.load_cli(subparsers)

    args = parser.parse_args(argv)
    args = vars(args)

    if os.path.exists(args['config']):
        utils.get_settings_from_config(args['config'], [
            'migrations-directory',
            'db-connection-string',
            ], args)
    utils.get_settings_from_entry_points(args)

    for name, value in DEFAULTS.items():
        if not args.get(name):
            args[name] = value

    if 'cmmd' not in args:
        parser.print_help()
        return parser.error('command missing')

    args['migrations_directory'] = os.path.relpath(
        args['migrations_directory'])

    return args['cmmd'](**args)

## Instruction:
Remove default config path (development.ini)
## Code After:

import argparse
import os
import sys

from . import commands, utils


DEFAULTS = {
    }


def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(description='DB Migrator')

    parser.add_argument('--migrations-directory')

    parser.add_argument('--config')

    parser.add_argument('--db-connection-string',
                        help='a psycopg2 db connection string')

    subparsers = parser.add_subparsers(help='commands')
    commands.load_cli(subparsers)

    args = parser.parse_args(argv)
    args = vars(args)

    if os.path.exists(args['config']):
        utils.get_settings_from_config(args['config'], [
            'migrations-directory',
            'db-connection-string',
            ], args)
    utils.get_settings_from_entry_points(args)

    for name, value in DEFAULTS.items():
        if not args.get(name):
            args[name] = value

    if 'cmmd' not in args:
        parser.print_help()
        return parser.error('command missing')

    args['migrations_directory'] = os.path.relpath(
        args['migrations_directory'])

    return args['cmmd'](**args)
