Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Smart usage does not include all optional command nodes #49

Open
NeunEinser opened this issue Nov 14, 2018 · 1 comment
Open

[Bug] Smart usage does not include all optional command nodes #49

NeunEinser opened this issue Nov 14, 2018 · 1 comment

Comments

@NeunEinser
Copy link

Because of the lack of documentation, I have no idea if this is by design or not.
Consider following example:

dispatcher.register(literal("foo")
    .executes(ctx -> 0)
    .then(literal("bar")
        .executes(ctx -> 1)
        .then(literal("baz")
            .executes( ctx -> 2)
        )
    )
);

for (String usage : dispatcher.getAllUsage(dispatcher.getRoot(), null, false)) {
    System.out.println(usage);
}

dispatcher.getSmartUsage(dispatcher.getRoot(), null).forEach((k, v) -> System.out.println(k + ": " + v));

The expected output is:

foo
foo bar
foo bar baz
<literal foo>: foo [bar] [baz]

The actual output is:

foo
foo bar
foo bar baz
<literal foo>: foo [bar]

Note, that the smart usage is missing the optional baz argument at the end.

The command dispatcher actually does have a javadoc, however for smart usage it only says "These forms may be mixed and matched to provide as much information about the child nodes as it can, without being too verbose". (These forms is referring to literal, <arg>, [opt] and (either|or)).
It's unclear how "providing as much information as it can without being too verbose" is actually meant.

Imo there is no reason not to provide this information. It's also confusing since the user probably does not expect any further possible arguments after bar.

@SoniEx2
Copy link

SoniEx2 commented Nov 30, 2022

wouldn't that be foo [bar [baz]]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants