@staticmethod<EOL><INDENT>def _parse_flags_and_options(command_elements):<DEDENT>
<EOL>is_arg = [not cmd_elem.startswith("<STR_LIT:->")<EOL>for cmd_elem in command_elements]<EOL>parsed_command_elements = set()<EOL>for i, cmd_elem in enumerate(command_elements):<EOL><INDENT>if is_arg[i]:<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>if is_arg[i + <NUM_LIT:1>]:<EOL><INDENT>parsed_command_elements.add(<EOL>(cmd_elem, command_elements[i + <NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>parsed_command_elements.add(cmd_elem)<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>parsed_command_elements.add(cmd_elem)<EOL><DEDENT><DEDENT>return parsed_command_elements<EOL>
Differentiate flags and option/argument pairs for validation.

We need a way to assert that each option is adjacent to and precedes 
its argument. This creates some difficulty since we want to be 
disregard order of the flags/option-argument pairs with respect to one 
another when we validate. The desire to validate a mixture of flags 
and option/argument pairs precludes some indexing-based approaches to 
the problem. Two strategies are most apparent, each with a minor 
pitfall. We can regard any command element starting with a hyphen as 
a flag or an option, and all others as arguments, but this excludes 
the possibility of negative integers as arguments. Or we could assume 
that each element with a double-hyphen prefix takes and argument, but 
this seems even less reasonable. Let's settle on the first strategy.

:param Iterable[str] command_elements: components of a command
:return Iterable[str | (str, str)]: collection of flags or pairs 
    of option and argument