TeXitoi / structopt

Parse command line arguments by defining a struct.
Other
2.71k stars 152 forks source link

Add derive for custom help messages appended after OPTIONS #402

Closed jackdorland closed 4 years ago

jackdorland commented 4 years ago

Hello! 👋

I'm trying to get my program to have an extra field in -h/--help, but I can't seem to do it with current StructOpt.

Currently, my help looks like this:

spacebin-cli 0.2.0
text sharing for astronauts

USAGE:
    space [FLAGS] [OPTIONS]

FLAGS:
        --debug      Debugging features
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -u, --upload <file>              File to upload
    -i, --instance <instance>        Instance URL to upload to (example: api.spaceb.in) [env: SPACEBIN_INSTANCE=]
                                     [default: https://api.spaceb.in]
    -p, --port <port>                Port to upload on [env: SPACEBIN_PORT=]  [default: 443]
        --result-url <result-url>    Result url (example: https://api.spaceb.in) [env: SPACEBIN_RESULT_URL=]  [default:
                                     https://api.spaceb.in/]
        --spinners <spinner-bool>    Whether or not to use terminal spinners [env: SPACEBIN_USE_SPINNERS=]  [default:
                                     true]

I'd like to append something to this that says:

PIPING:
        Need a quick link to the output of a command?
        You can pipe any command's output directly into `space`, like this:

        $ echo "foo, bar" | space

But I can't figure out a way to do this without just using clap without StructOpt

CreepySkeleton commented 4 years ago

Use after_help:


#[derive(StructOpt)]
#[structopt(
    after_help = 
"PIPING:
        Need a quick link to the output of a command?
        You can pipe any command's output directly into `space`, like this:

        $ echo \"foo, bar\" | space"
)]
struct Opts {}