import optparse


def parse_command_line(argv):
    """Command line options parser for the script
    """
    usage = "Usage: %prog [options] <CSV input file>"

    parser = optparse.OptionParser(usage=usage)

    parser.add_option("-c", "--column", action="store",
                      type="string", dest="column", default="Online Section",
                      help="Label column name (default: 'Online Section')")
    parser.add_option("-d", "--delimiter", action="store",
                      type="string", dest="delimiter", default=";",
                      help="Delimiter used to split label if multiple labels (default: ';')")

    parser.add_option("-o", "--outfile", action="store",
                      type="string", dest="outfile", default="subset.csv",
                      help="Subseting output CSV filename (default: 'subset.csv')")

    parser.add_option("-r", "--remove", action="store",
                      type="string", dest="remove", default="NA",
                      help="Labels name to be removed (default: 'NA')")
    parser.add_option("-b", "--begin", action="store",
                      type="int", dest="begin", default=1,
                      help="Begin row number (default: 1)")
    parser.add_option("-e", "--end", action="store",
                      type="int", dest="end", default=0,
                      help="End row number (default: 0)")

    parser.add_option("--selected-cols", action="store",
                      type="string", dest="selected_cols", default=None,
                      help="Selected columns name (default: 'All')")

    parser.add_option("-s", "--size", action="store",
                      type="int", dest="size", default=0,
                      help="Random size (default: 0)")

    parser.add_option("-n", "--n-per-label", action="store",
                      type="int", dest="nperlabel", default=0,
                      help="N per label (stratified) (default: 0)")

    parser.add_option("--no-report", action="store_true",
                      dest="noreport", default=False,
                      help="Don't report data statistics (default: False)")

    return parser.parse_args(argv)