import re


def parse_yotta_target_cmd_output(line):
    """! Function parsed output from command 'yotta --plain target'
         looking for valid target names. First one will be used as 'default'
         of currently set yotta target
    @param line Line of text from 'yotta target' command
    @return Yotta target name, None if not parsed
    @details

    Example call to 'yotta target' command (all lines)
    $ yotta --plain target
    frdm-k64f-gcc 2.0.0
    kinetis-k64-gcc 2.2.0
    mbed-gcc 1.2.2

    """
    # Regular expression to parse stings like: 'frdm-k64f-gcc 2.0.0'
    m = re.search(r'[\w\d_-]+ \d+\.\d+\.\d+', line)
    if m and len(m.group()):
        result = line.split()[0]
        return result
    return None