Spongeapi: Help message for flags is illformatted

Created on 13 Oct 2017  路  4Comments  路  Source: SpongePowered/SpongeAPI

The help message for flags is illformatted and confusing.

For example let's take this simple flag:

GenericArguments.flags().flag("h", "-history").buildWith(GenericArguments.none())

The resulting help text formats this flag like this: [-h|-history <h>]

Foremost, the long flag should have two dashes instead of just one. But also the <h> is confusing, as <> normally indicate a required argument. I therefore propose these alternative formats:

  • Simple: [-h|--history]
  • Unix style: [-h, --history]
  • With Parentheses: [-h|--history (h)]
command

Most helpful comment

For

Sponge.getCommandManager().register(this,
        CommandSpec.builder().executor((a, b) -> CommandResult.success()).arguments(
                GenericArguments.flags()
                        .flag("h", "-history")
                        .permissionFlag("test", "t", "-test")
                        .valueFlag(GenericArguments.bool(Text.of("bool")), "b", "-bool")
                        .buildWith(GenericArguments.none())
        ).build(), "test");

I will get /test [-h|--history] [-b|--bool <bool>] [-t|--test], which should solve the immediate problem this issue raises.

All 4 comments

+1 for linux style.

Most of your points are valid and I plan to solve them in a more emphatic way for the command refactor: #1587. However, formatting the flags in the current system unix style would go against the rest of the usage text: | is used to indicate "or" elsewhere.

I'm not against the unix style, mind, that would be a trival change if there is an overwhelming desire for this. I'm just going to make the minimal changes to make the usage more useful right now.

For

Sponge.getCommandManager().register(this,
        CommandSpec.builder().executor((a, b) -> CommandResult.success()).arguments(
                GenericArguments.flags()
                        .flag("h", "-history")
                        .permissionFlag("test", "t", "-test")
                        .valueFlag(GenericArguments.bool(Text.of("bool")), "b", "-bool")
                        .buildWith(GenericArguments.none())
        ).build(), "test");

I will get /test [-h|--history] [-b|--bool <bool>] [-t|--test], which should solve the immediate problem this issue raises.

This looks very good! Thank you for the quick fix!

Was this page helpful?
0 / 5 - 0 ratings