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

sponge command throwing error with no subcommand #1953

Closed
phit opened this issue Jun 22, 2018 · 3 comments
Closed

sponge command throwing error with no subcommand #1953

phit opened this issue Jun 22, 2018 · 3 comments
Assignees
Labels
system: command version: 1.12 (u) API: 7 (unsupported since May 21st 2021)

Comments

@phit
Copy link
Contributor

phit commented Jun 22, 2018

I am currently running

  • SpongeForge version: 7.1.0-BETA-3218
  • SpongeVanilla version: 1.12.2-7.1.0-BETA-67
  • Plugins/Mods: /

Issue Description
type /sponge in console, get reply

[02:41:45] [Server thread/INFO]: Invalid subcommand state -- no more than one mapping may be provided for child arg child0

expected result

[02:40:10] [Server thread/INFO]: Not enough arguments!
[02:40:10] [Server thread/INFO]: Usage: /sponge which|audit|plugins|timings|heap|version|[--global|-g] [--world|-w <world>] [--dimension|-d <dimension>] reload|chunks|tps|save|config
@limbo-app limbo-app added the status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage label Jun 22, 2018
@phit phit changed the title sponge command throwing error when no subcommand sponge command throwing error with no subcommand Jun 22, 2018
@phit phit added system: command version: 1.12 (u) API: 7 (unsupported since May 21st 2021) labels Jun 22, 2018
@limbo-app limbo-app removed the status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage label Jun 22, 2018
@SimonFlash
Copy link
Contributor

SimonFlash commented Jun 22, 2018

The problem here is that Sponge's CommandElement for non-flag children is created with a fallback executor but not a CommandElement to handle the parsing for it (here). This causes the parse method to return without handling the verification that a subcommand has been specified as there's no fallback element (here).

The solution to this is to create the ChildCommandElementExecutor with the delegate element as both the fallback executor and fallback element.

final ChildCommandElementExecutor flagChildren = new ChildCommandElementExecutor(null);
final ChildCommandElementExecutor nonFlagChildren = new ChildCommandElementExecutor(flagChildren, flagChildren, true);

@ryantheleach
Copy link
Contributor

Considering it was working previously, is @SimonFlash 's suggestion a work around? or is the current behavior unintended given the current command code?

@dualspiral
Copy link
Contributor

dualspiral commented Jun 22, 2018

Workaround should work - at least ish, though I don't think it'll give the correct usage (I think, haven't tested it, this is skimming code while in bed), reasoning is not completely correct.

Note that these child commands are not written in the normal way. The children arguments are specified differently, so the expectation is that these arguments should create the usage. As firstParsing is creating the commands, that should bail without parsing any commands - obviously it is not. This is probably because I've got some check for standard child commands that has messed up in this case, likely due to improper validation that Simon suggested.

I'll fix it either tonight or this weekend.

@dualspiral dualspiral self-assigned this Jun 22, 2018
dualspiral added a commit that referenced this issue Jun 22, 2018
* Bump SpongeAPI for command fixes
* Fix error message on /sponge when no subcommand is provided - This is a quick fix, probably want something a bit better than this
later - Fixes #1953
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system: command version: 1.12 (u) API: 7 (unsupported since May 21st 2021)
Projects
None yet
Development

No branches or pull requests

5 participants