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

List argument nodes (not types) #120

Open
SoniEx2 opened this issue Nov 30, 2022 · 0 comments · May be fixed by #121
Open

List argument nodes (not types) #120

SoniEx2 opened this issue Nov 30, 2022 · 0 comments · May be fixed by #121

Comments

@SoniEx2
Copy link

SoniEx2 commented Nov 30, 2022

There should be an argument node that allows infinite repeat, for example, something along the lines of:

cd.register(
  literal("addAll")
  .then(
    list("names", string())
    .executes(c -> list.addAll(getStringList(c, "names")))
  )
  .then(
    literal("from")
    .then(
      argument("name", string())
      .executes(c -> list.addAddFrom(getString(c, "name")))
    )
  )
);

would allow stuff like:

/addAll foo bar baz
/addAll from qux

(while stuff like /addAll from and /addAll from foo bar would be disallowed. however, in this case, due to the (deliberate) use of string(), the workaround is pretty obvious: /addAll "from" or /addAll "from" foo bar.)

Further, something like:

cd.register(
  literal("enable_recursive")
  .then(
    list("names", string())
    .executes(c -> ...)
    .then(
      literal("except")
      .then(
        list("excluded", string())
        .executes(c -> ...)
      )
    )
  )
);

would allow stuff like:

/enable_recursive foo bar
/enable_recursive foo bar except qux
/enable_recursive foo bar "except"

etc.

@SoniEx2 SoniEx2 linked a pull request Dec 1, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant