Parses arguments, returns (options, args).

def parse_args(args=None):
    '''Parses arguments, returns (options, args).'''
    from argparse import ArgumentParser

    if args is None:
        args = sys.argv

    parser = ArgumentParser(description='Example app for drawing shapes from '
                            'dataframe, scaled to fit to GTK canvas while '
                            'preserving aspect ratio (a.k.a., aspect fit).')
    parser.add_argument('-p', '--padding-fraction', type=float, default=0)
    parser.add_argument('--connections-color', default='#ffffff')
    parser.add_argument('--connections-alpha', type=float, default=.5)
    parser.add_argument('--connections-width', type=float, default=1)
    parser.add_argument('-n', '--plugin-name', default=None)
    parser.add_argument('-a', '--allocation', default=None,
                        help='Window allocation: x, y, width, height (JSON'
                        'object)')
    parser.add_argument('-d', '--debug', action='store_true',
                        help='Include IPython button for debugging.')

    subparsers = parser.add_subparsers(help='help for subcommand',
                                       dest='command')

    parser_fixed = subparsers.add_parser('fixed', help='Start view with fixed'
                                         'name and hub URI.')
    parser_fixed.add_argument('hub_uri')

    parser_config = subparsers.add_parser('configurable', help='Start view '
                                          'with configurable name and hub '
                                          'URI.')
    parser_config.add_argument('hub_uri', nargs='?')

    args = parser.parse_args()
    return args