()
| 356 | return out |
| 357 | |
| 358 | def get_command(): |
| 359 | output = run("stoke --help | grep \"^ \"") |
| 360 | subcommands = [] |
| 361 | cmd = Command(None, "stoke", "", subcommands, []) |
| 362 | subsubmap = {} |
| 363 | for line in output.split("\n"): |
| 364 | if len(line) > 0: |
| 365 | match = re.search(r"^ (.*[^ ]) +([^ ].*)$", line) |
| 366 | help = match.group(2) |
| 367 | full = match.group(1) |
| 368 | parts = full.split(" ") |
| 369 | if (len(parts) == 1): |
| 370 | args = get_arguments(full) |
| 371 | sub = Command(cmd, full, help, [], args) |
| 372 | subcommands.append(sub) |
| 373 | else: |
| 374 | assert len(parts) == 2 |
| 375 | if not parts[0] in subsubmap: |
| 376 | subsubmap[parts[0]] = [] |
| 377 | subsubmap[parts[0]].append({ |
| 378 | 'name': parts[1], |
| 379 | 'help': help |
| 380 | }) |
| 381 | for sub, subsubs in subsubmap.iteritems(): |
| 382 | subsubcommands = [] |
| 383 | subcmd = Command(cmd, sub, sub + " commands", subsubcommands, []) |
| 384 | subcommands.append(subcmd) |
| 385 | for subsub in subsubs: |
| 386 | args = get_arguments(sub + " " + subsub['name']) |
| 387 | subsubcommands.append(Command(subcmd, subsub['name'], subsub['help'], [], args)) |
| 388 | return cmd |
| 389 | |
| 390 | def get_arguments(subcommand): |
| 391 | data = run("stoke " + subcommand + " --help | grep \"^ \(-\| \)\"") |
no test coverage detected