Changeset 8a3acad


Ignore:
Timestamp:
Sep 14, 2017, 1:36:08 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
5db398e
Parents:
70762c5
Message:

python/lib/aubio/cmd.py: add help subcommand

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/cmd.py

    r70762c5 r8a3acad  
    2222    subparsers = parser.add_subparsers(title='commands', dest='command',
    2323            metavar="")
     24
     25    parser_add_subcommand_help(subparsers)
    2426
    2527    parser_add_subcommand_onset(subparsers)
     
    3335
    3436    return parser
     37
     38def parser_add_subcommand_help(subparsers):
     39    # global help subcommand
     40    subparsers.add_parser('help',
     41            help='show help message',
     42            formatter_class = argparse.ArgumentDefaultsHelpFormatter)
    3543
    3644def parser_add_subcommand_onset(subparsers):
     
    437445    elif 'verbose' in args and args.verbose > 3:
    438446        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']:
    440448        # no command given, print help and return 1
    441449        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)
    443454    elif not args.source_uri and not args.source_uri2:
    444455        sys.stderr.write("Error: a source is required\n")
Note: See TracChangeset for help on using the changeset viewer.