Skip to content

Instantly share code, notes, and snippets.

@Romain-P
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save Romain-P/f1f2869affb107ba30ef to your computer and use it in GitHub Desktop.

Select an option

Save Romain-P/f1f2869affb107ba30ef to your computer and use it in GitHub Desktop.
My command DSL
binder.put("character", Commands.new("character", (c) -> c
.withSub("customize", (sub) -> sub.to(CustomizeAction.class))
.withSub("remove", (sub) -> sub
.to(RemoveAction.class)
.withArg("definitly", "yes", "no")) //equals withRequiredArg("state" new String[] { "on", "off" })
.withSub("reload", (sub) -> sub.to(ReloadAction.class))
.iff(GmLevelCondition.class);
.withAliases("!personnage", "!joueur"));
//!character -customize
//!character -remove (-definitly(yes/no))
//!character -reload
binder.put("kolizeum", Commands.new("kolizeum", (c) -> c //possible without action, !kolizeum will return an error syntax
.withRequiredArg("state", "on", "off") //required
.withArg("group", "yes", "no"));
//!kolizeum -state(on/off) -group(yes/no)
binder.put("world", Commands.new("world", (c) -> c
.to(SpeakToWorldAction.class)
.withSpacedRequiredArg("message")); //note spaced allows an argument with spaces (need to be at the last arg)
//!world #message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment