Skip to content

List argument nodes (not types) #120

Open
@SoniEx2

Description

@SoniEx2

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions