def visit_short_flag_list(s, loc, toks): return [ Flag.from_synonyms( [FlagSynonym(name="-" + flag, argtype=EmptyFlagArg())], description=None) for flag in toks[1:] ]
options_placeholder = (Regex( "options?", flags=re.IGNORECASE).suppress().setName("OptionsPlaceholder")) list_element = ( (OneOrMore(options_placeholder ^ mandatory_element ^ variable_element) + Literal(".")[2, 3] + Optional(options_placeholder ^ mandatory_element ^ variable_element) ).setParseAction(visit_list_element).setName("list_element")) """ When one or more arguments are allowed, e.g. "<in2.bam> ... <inN.bam>" """ usage_flag = (And([flag_with_arg ]).setParseAction(lambda s, loc, toks: Flag.from_synonyms( toks, description="")).setName("usage_flag")) usage_element <<= Or([ optional_section, list_element, # short_flag_list, usage_flag, variable_element, options_placeholder, mandatory_element, ]).setName("usage_element") stack = [1] def visit_usage(s, loc, toks):