import optparse


def parse_options(args=None, values=None):
    """
    Define and parse `optparse` options for command-line usage.
    """
    usage = """%prog [options] [TOOLBOX_PATH]"""
    desc = "Generate ArcGIS Metadata from markdown'd toolbox code. "

    parser = optparse.OptionParser(usage=usage, description=desc)
    parser.add_option("-y", "--yes", dest="yes", default=None, action='store_true',
                      help="Implicit confirmation to run")

    (options, args) = parser.parse_args(args, values)

    if len(args) == 0:
        raise Exception("Input toolbox needed")
    else:
        input_file = args[0]


    opts = {
        'input': input_file,
        'implicit_run': options.yes,
    }

    return opts