allthemusicllc / atm-cli

Command line tool for generating and working with MIDI files.
http://allthemusic.info
Other
1.39k stars 107 forks source link

Use clap's SubcommandRequiredElseHelp setting #22

Closed DirkyJerky closed 3 years ago

DirkyJerky commented 4 years ago

Clap has an app setting (SubcommandRequiredElseHelp) to handle applications that require a subcommand present to run. This commit enables that setting.

This changes the output of when atm is run without a subcommand: Before change:

thread 'main' panicked at 'Did not receive directive', src/cli.rs:133:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

After change:

atm 0.2.0
All The Music, LLC
Tools for generating and working with MIDI files.  This app was created as part of an effort to generate by brute-force
billions of melodies, and is tailored for that use case.

USAGE:
    atm <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    batch        Generate by brute-force MIDI files containing permutations of a sequence of MIDI pitches
    help         Prints this message or the help of the given subcommand(s)
    partition    Generate the output path from the 'batch' directive for a given MIDI pitch sequence
    single       Generate single MIDI file from provided MIDI pitch sequence

An alternative would be using the SubcommandRequired option, which would change the output to:

error: 'atm' requires a subcommand, but one was not provided

USAGE:
    atm <SUBCOMMAND>

For more information try --help

Although I believe outputting the help message to be the better option in this case.

allthemusicllc commented 3 years ago

Fixed here: https://github.com/allthemusicllc/atm-cli/blob/master/src/cli.rs#L202.