import logging
log = logging.getLogger(__file__)


def db_parser(prog_name='bin/load_db'):
    """ create a generic database commandline arg PARSER """
    import argparse
    parser = argparse.ArgumentParser(
        prog=prog_name,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter
    )
    parser.add_argument(
        '--database_url',
        '-d',
        required='true',
        help="(geo) database url ala dialect+driver://user:password@host/dbname[?key=value..]"
    )
    parser.add_argument(
        '--schema',
        '-schema',
        '-s',
        help="database schema"
    )
    parser.add_argument(
        '--is_geospatial',
        '-geo',
        '-g',
        action="store_true",
        help="add geometry columns"
    )
    parser.add_argument(
        '--create',
        '-create',
        '-c',
        action="store_true",
        help="drop / create database tables for vehicles"
    )
    parser.add_argument(
        '--clear',
        '-clear',
        '-cf',
        action="store_true",
        help="clear table(s) before loading"
    )
    return parser


def gtfs_parser():
    """ create a generic database commandline arg PARSER """
    parser = db_parser('bin/load_gtfs')
    parser.add_argument(
        '--agency',
        '-agency',
        '-a',
        default="trimet",
        help="agency name (string)"
    )
    parser.add_argument(
        '--url',
        '-url',
        '-u',
        required='true',
        help="url to gtfs (or gtfs-realtime) data"
    )
    return parser


@@ -81,16 +81,78 @@
 load_db'
+, tables=%5B'Could be (Decarative) Base.metadata.sorted_tables'%5D
 ):%0A    %22
@@ -1137,32 +1137,205 @@
  loading%22%0A    )%0A
+    parser.add_argument(%0A        '--tables',%0A        choices=tables, default=None, nargs='*',%0A        help=%22Limited list of TABLES to load, if blank, load all tables%22%0A    )%0A
     return parse

add tables to match cmdline gtfsdb