import optparse


def parse_command_line(str_input=None):
    """
        This will parse through the command line arguments
    """
    if str_input is None:
        parser = optparse.OptionParser()
    else:
        parser = optparse.OptionParser(str_input)


    parser.add_option("-s", "--start", dest="start", default=None,
                      help="Use the provided start time instead of the first time in the data. format is ISO8601: 2015-11-01T15:24:00Z")
    parser.add_option("-e", "--end", dest="end", default=None,
                      help="Use the provided end time for the plot. format is ISO8601: 2015-11-01T15:24:00Z")

    parser.add_option("-p", "--path", dest="path",
                      help="Use data from the provided digital RF data <path>.")
    parser.add_option("-c", "--channel", dest="channel", default="ch0:0",
                      help="Use data from the provided digital RF channel <channel>:<subchannel>.")

    parser.add_option("-d", "--decimation", dest="decimation", default=1,
                      type="int", help="The decimation factor for the data (integer).")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
                      default=False, help="Print status messages to stdout.")
    parser.add_option("-o", "--outname", dest="outname", default=None,
                      type=str, help="Name of file that figure will be saved under.")
    parser.add_option("-f", "--freqshift", dest="freqshift", default=None,
                      type=float, help="Frequency shift in Hz for the signal.")
    parser.add_option("-a", "--audiosampling", dest="audiosampling", default=44100.,
                      type=float, help="Audio sampling frequency in Hz.")
    parser.add_option("-t", "--timedilation", dest="timedilation", default=1.,
                      type=float, help="Time dilation of data.")
    parser.add_option("-b", "--blocks", dest="blocks", default=1,
                      type=int, help="Number of blocks the file will be broken into.")


    (options, args) = parser.parse_args()

    return (options, args)