def test_all(test: HelpText): """ Tests that generate_names can work on real-life Commands without exceeding reasonable system resources """ with open(resource_filename("test", test.path)) as fp: help_text = fp.read() cmd = parse_help(test.cmd, help_text) WrapperGenerator().choose_variable_names([*cmd.positional, *cmd.named])
def test_round_trip(bwamem_help): command = parse_help(["bwa", "mem"], bwamem_help) # Dump buffer = StringIO() yaml.dump(command, buffer) # Load buffer.seek(0) output = yaml.load(buffer) # Assert the round trip worked assert command == output
def test_all(test: HelpText): """ A comprehensive end-to-end test that tests the parser and converters, using the test data files """ with open(resource_filename("test", test.path)) as fp: help_text = fp.read() cmd = parse_help(test.cmd, help_text) # Check we parsed the arguments correctly # Since we aren't exploring here, we can't distinguish between positionals and subcommands, so we can sum them assert len(cmd.positional) == test.positional + test.subcommands assert len(cmd.named) == test.named # Check that the help text is included in the command assert cmd.help_text == help_text # Check the converters work convert_validate(cmd, explore=False)
help="Read a command help from stdin and output a tool definition to stdout" ) @opt_cmd @opt_pos @opt_generate_names @opt_case @click.option( "--format", "-f", type=click.Choice(["wdl", "cwl", "yml"]), default="cwl", help="The language in which to output the CLI wrapper", ) def pipe(cmd, pos, generate_names, case, format): stdin = "".join(sys.stdin.readlines()) command = parse_help(cmd, stdin) converter_cls = WrapperGenerator.choose_converter(format) converter = converter_cls( generate_names=generate_names, ignore_positionals=not pos, case=case, ) output = converter.save_to_string(command) print(output) @main.command(help="Output a representation of the internal grammar") @opt_pos def railroad(pos): try:
def test_bwa(parser, bwamem_help): # Parse help command = parse_help(["bwa", "mem"], text=bwamem_help) assert len(command.named) == 36 assert len(command.positional) == 3
def test_bwa_root(bwa_help): command = parse_help(["bwa"], bwa_help) assert len(command.named) == 0 assert len(command.positional) == 14 assert command.positional[0].name == "index" assert command.positional[-1].name == "bwt2sa"