Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -22,6 +22,8 @@ def aubio_parser(): · 21 unmodified lines | ||
| 22 | 22 | subparsers = parser.add_subparsers(title='commands', dest='command', |
| 23 | 23 | metavar="") |
| 24 | 24 | |
| 25 | + parser_add_subcommand_help(subparsers) | |
| 26 | + | |
| 25 | 27 | parser_add_subcommand_onset(subparsers) |
| 26 | 28 | parser_add_subcommand_pitch(subparsers) |
| 27 | 29 | parser_add_subcommand_beat(subparsers) |
| @@ -33,6 +35,12 @@ def aubio_parser(): · 5 unmodified lines | ||
| 33 | 35 | |
| 34 | 36 | return parser |
| 35 | 37 | |
| 38 | +def parser_add_subcommand_help(subparsers): | |
| 39 | + # global help subcommand | |
| 40 | + subparsers.add_parser('help', | |
| 41 | + help='show help message', | |
| 42 | + formatter_class = argparse.ArgumentDefaultsHelpFormatter) | |
| 43 | + | |
| 36 | 44 | def parser_add_subcommand_onset(subparsers): |
| 37 | 45 | # onset subcommand |
| 38 | 46 | subparser = subparsers.add_parser('onset', |
| @@ -436,10 +444,13 @@ def main(): · 397 unmodified lines | ||
| 436 | 444 | sys.exit(0) |
| 437 | 445 | elif 'verbose' in args and args.verbose > 3: |
| 438 | 446 | sys.stderr.write('aubio version ' + aubio.version + '\n') |
| 439 | − if 'command' not in args or args.command is None: | |
| 447 | + if 'command' not in args or args.command is None or args.command in ['help']: | |
| 440 | 448 | # no command given, print help and return 1 |
| 441 | 449 | parser.print_help() |
| 442 | − sys.exit(1) | |
| 450 | + if args.command and args.command in ['help']: | |
| 451 | + sys.exit(0) | |
| 452 | + else: | |
| 453 | + sys.exit(1) | |
| 443 | 454 | elif not args.source_uri and not args.source_uri2: |
| 444 | 455 | sys.stderr.write("Error: a source is required\n") |
| 445 | 456 | parser.print_help() |