def match(cmd, s):
    """ Check if cmd has the required parts of s and any of the optional part.
    """
    parts = s.split('-')
    start = parts[0]
    if len(parts) > 1:
        end = parts[1]
    else:
        end = ""
    return cmd.startswith(start) and (start+end).startswith(cmd)