Browse Source

Fix style for `CommandDataBuilder`

pull/12/head
Anton Tarasenko 2 years ago
parent
commit
626124335d
  1. 31
      sources/LevelAPI/Features/Commands/BuiltInCommands/ACommandHelp.uc
  2. 1195
      sources/LevelAPI/Features/Commands/CommandDataBuilder.uc
  3. 21
      sources/LevelAPI/Features/Commands/Tests/MockCommandA.uc
  4. 58
      sources/LevelAPI/Features/Commands/Tests/MockCommandB.uc
  5. 24
      sources/LevelAPI/Features/Commands/Tests/TEST_CommandDataBuilder.uc
  6. 103
      sources/Users/ACommandUserGroups.uc

31
sources/LevelAPI/Features/Commands/BuiltInCommands/ACommandHelp.uc

@ -102,21 +102,22 @@ protected function Finalizer()
protected function BuildData(CommandDataBuilder builder)
{
builder.Name(P("help")).Group(P("core"))
.Summary(P("Displays detailed information about available commands."));
builder.OptionalParams()
.ParamTextList(P("commands"))
.Describe(P("Displays information about all specified commands."));
builder.Option(P("aliases"))
.Describe(P("When displaying available commands, specifying this flag"
@ "will additionally make command to display all of their available"
@ "aliases."))
.Option(P("list"))
.Describe(P("Display available commands. Optionally command groups can"
@ "be specified and then only commands from such groups will be"
@ "listed. Otherwise all commands will be displayed."))
.OptionalParams()
.ParamTextList(P("groups"));
builder.Name(P("help"));
builder.Group(P("core"));
builder.Summary(P("Displays detailed information about available commands."));
builder.OptionalParams();
builder.ParamTextList(P("commands"));
builder.Option(P("aliases"));
builder.Describe(P("When displaying available commands, specifying this flag will additionally"
@ "make command to display all of their available aliases."));
builder.Option(P("list"));
builder.Describe(P("Display available commands. Optionally command groups can be specified and"
@ "then only commands from such groups will be listed. Otherwise all commands will"
@ "be displayed."));
builder.OptionalParams();
builder.ParamTextList(P("groups"));
}
protected function Executed(Command.CallData callData, EPlayer callerPlayer)

1195
sources/LevelAPI/Features/Commands/CommandDataBuilder.uc

File diff suppressed because it is too large Load Diff

21
sources/LevelAPI/Features/Commands/Tests/MockCommandA.uc

@ -21,16 +21,17 @@ class MockCommandA extends Command;
protected function BuildData(CommandDataBuilder builder)
{
builder.ParamObject(P("just_obj"))
.ParamArrayList(P("manyLists"))
.OptionalParams()
.ParamObject(P("last_obj"));
builder.SubCommand(P("simple"))
.ParamBooleanList(P("isItSimple?"))
.ParamInteger(P("integer variable"), P("int"))
.OptionalParams()
.ParamNumberList(P("numeric list"), P("list"))
.ParamTextList(P("another list"));
builder.ParamObject(P("just_obj"));
builder.ParamArrayList(P("manyLists"));
builder.OptionalParams();
builder.ParamObject(P("last_obj"));
builder.SubCommand(P("simple"));
builder.ParamBooleanList(P("isItSimple?"));
builder.ParamInteger(P("integer variable"), P("int"));
builder.OptionalParams();
builder.ParamNumberList(P("numeric list"), P("list"));
builder.ParamTextList(P("another list"));
}
defaultproperties

58
sources/LevelAPI/Features/Commands/Tests/MockCommandB.uc

@ -21,31 +21,39 @@ class MockCommandB extends Command;
protected function BuildData(CommandDataBuilder builder)
{
builder.ParamArray(P("just_array"))
.ParamText(P("just_text"));
builder.Option(P("values"))
.ParamIntegerList(P("types"));
builder.Option(P("long"))
.ParamInteger(P("num"))
.ParamNumberList(P("text"))
.ParamBoolean(P("huh"));
builder.Option(P("type"), P("t"))
.ParamText(P("type"));
builder.Option(P("Test"))
.ParamText(P("to_test"));
builder.Option(P("silent"))
.Option(P("forced"))
.Option(P("verbose"), P("V"))
.Option(P("actual"));
builder.SubCommand(P("do"))
.OptionalParams()
.ParamNumberList(P("numeric list"), P("list"))
.ParamBoolean(P("maybe"));
builder.Option(P("remainder"))
.ParamRemainder(P("everything"));
builder.SubCommand(P("json"))
.ParamJSON(P("first_json"))
.ParamJSONList(P("other_json"));
builder.ParamArray(P("just_array"));
builder.ParamText(P("just_text"));
builder.Option(P("values"));
builder.ParamIntegerList(P("types"));
builder.Option(P("long"));
builder.ParamInteger(P("num"));
builder.ParamNumberList(P("text"));
builder.ParamBoolean(P("huh"));
builder.Option(P("type"), P("t"));
builder.ParamText(P("type"));
builder.Option(P("Test"));
builder.ParamText(P("to_test"));
builder.Option(P("silent"));
builder.Option(P("forced"));
builder.Option(P("verbose"), P("V"));
builder.Option(P("actual"));
builder.SubCommand(P("do"));
builder.OptionalParams();
builder.ParamNumberList(P("numeric list"), P("list"));
builder.ParamBoolean(P("maybe"));
builder.Option(P("remainder"));
builder.ParamRemainder(P("everything"));
builder.SubCommand(P("json"));
builder.ParamJSON(P("first_json"));
builder.ParamJSONList(P("other_json"));
}
defaultproperties

24
sources/LevelAPI/Features/Commands/Tests/TEST_CommandDataBuilder.uc

@ -24,27 +24,33 @@ class TEST_CommandDataBuilder extends TestCase
protected static function CommandDataBuilder PrepareBuilder()
{
local CommandDataBuilder builder;
builder =
CommandDataBuilder(__().memory.Allocate(class'CommandDataBuilder'));
builder.ParamNumber(P("var")).ParamText(P("str_var"), P("otherName"));
builder = CommandDataBuilder(__().memory.Allocate(class'CommandDataBuilder'));
builder.ParamNumber(P("var"));
builder.ParamText(P("str_var"), P("otherName"));
builder.OptionalParams();
builder.Describe(P("Simple command"));
builder.ParamBooleanList(P("list"), PBF_OnOff);
// Subcommands
builder.SubCommand(P("sub")).ParamArray(P("array_var"));
builder.SubCommand(P("sub"));
builder.ParamArray(P("array_var"));
builder.Describe(P("Alternative command!"));
builder.ParamIntegerList(P("int"));
builder.SubCommand(P("empty"));
builder.Describe(P("Empty one!"));
builder.SubCommand(P("huh")).ParamNumber(P("list"));
builder.SubCommand(P("sub")).ParamObjectList(P("one_more"), P("but"));
builder.SubCommand(P("huh"));
builder.ParamNumber(P("list"));
builder.SubCommand(P("sub"));
builder.ParamObjectList(P("one_more"), P("but"));
builder.Describe(P("Alternative command! Updated!"));
// Options
builder.Option(P("silent")).Describe(P("Just an option, I dunno."));
builder.Option(P("silent"));
builder.Describe(P("Just an option, I dunno."));
builder.Option(P("Params"), P("d"));
builder.ParamBoolean(P("www"), PBF_YesNo, P("random"));
builder.OptionalParams().ParamIntegerList(P("www2"));
return builder.RequireTarget();
builder.OptionalParams();
builder.ParamIntegerList(P("www2"));
builder.RequireTarget();
return builder;
}
protected static function Command.SubCommand GetSubCommand(

103
sources/Users/ACommandUserGroups.uc

@ -22,56 +22,59 @@ class ACommandUserGroups extends Command
protected function BuildData(CommandDataBuilder builder)
{
builder.Name(P("usergroups"))
.Group(P("admin"))
.Summary(P("User groups management."))
.Describe(P("Allows to add/remove user groups and users to these:"
@ "groups. Changes made by it will always affect current session,"
@ "but might fail to be saved in case user groups are stored in"
@ "a database that is either corrupted or in read-only mode."));
builder.SubCommand(P("list"))
.Describe(P("Lists specified groups along with users that belong to"
@ "them. If no groups were specified at all - lists all available"
@ "groups."))
.OptionalParams()
.ParamTextList(P("groups"));
builder.SubCommand(P("add"))
.Describe(P("Adds a new group"))
.ParamText(P("group_name"));
builder.SubCommand(P("remove"))
.Describe(P("Removes a group"))
.ParamText(P("group_name"));
builder.SubCommand(P("addplayer"))
.Describe(F("Adds new user to the group, specified by the player"
@ "selector. Can add several players at once."
@ "Allows to also optionally specify annotation"
@ "(human-readable name) that can be thought of as"
@ "a {$TextEmphasis comment}. If annotation isn't specified"
@ "current nickname will be used as one."))
.ParamText(P("group_name"))
.ParamPlayers(P("player_selector"))
.OptionalParams()
.ParamText(P("annotation"));
builder.SubCommand(P("removeplayer"))
.Describe(P("Removes user from the group, specified by player selector."
@ "Can remove several players at once."))
.ParamText(P("group_name"))
.ParamPlayers(P("player_selector"));
builder.SubCommand(P("adduser"))
.Describe(F("Adds new user to the group. Allows to also optionally"
@ "specify annotation (human-readable name) that can be thought of"
@ "as a {$TextEmphasis comment}."))
.ParamText(P("group_name"))
.ParamText(P("user_id"))
.OptionalParams()
.ParamText(P("annotation"));
builder.SubCommand(P("removeuser"))
.Describe(P("Removes user from the group. User can be specified by both"
@ "user's id or annotation, with id taking priority."))
.ParamText(P("group_name"))
.ParamText(P("user_name"));
builder.Option(P("force"))
.Describe(P("Allows to force usage of invalid user IDs."));
builder.Name(P("usergroups"));
builder.Group(P("admin"));
builder.Summary(P("User groups management."));
builder.Describe(P("Allows to add/remove user groups and users to these: groups. Changes made"
@ "by it will always affect current session, but might fail to be saved in case user groups"
@ "are stored in a database that is either corrupted or in read-only mode."));
builder.SubCommand(P("list"));
builder.Describe(P("Lists specified groups along with users that belong to them. If no groups"
@ "were specified at all - lists all available groups."));
builder.OptionalParams();
builder.ParamTextList(P("groups"));
builder.SubCommand(P("add"));
builder.Describe(P("Adds a new group"));
builder.ParamText(P("group_name"));
builder.SubCommand(P("remove"));
builder.Describe(P("Removes a group"));
builder.ParamText(P("group_name"));
builder.SubCommand(P("addplayer"));
builder.Describe(F("Adds new user to the group, specified by the player selector. Can add"
@ "several players at once. Allows to also optionally specify annotation (human-readable"
@ "name) that can be thought of as a {$TextEmphasis comment}. If annotation isn't"
@ "specified current nickname will be used as one."));
builder.ParamText(P("group_name"));
builder.ParamPlayers(P("player_selector"));
builder.OptionalParams();
builder.ParamText(P("annotation"));
builder.SubCommand(P("removeplayer"));
builder.Describe(P("Removes user from the group, specified by player selector."
@ "Can remove several players at once."));
builder.ParamText(P("group_name"));
builder.ParamPlayers(P("player_selector"));
builder.SubCommand(P("adduser"));
builder.Describe(F("Adds new user to the group. Allows to also optionally specify annotation"
@ "(human-readable name) that can be thought of as a {$TextEmphasis comment}."));
builder.ParamText(P("group_name"));
builder.ParamText(P("user_id"));
builder.OptionalParams();
builder.ParamText(P("annotation"));
builder.SubCommand(P("removeuser"));
builder.Describe(P("Removes user from the group. User can be specified by both user's id or"
@ "annotation, with id taking priority."));
builder.ParamText(P("group_name"));
builder.ParamText(P("user_name"));
builder.Option(P("force"));
builder.Describe(P("Allows to force usage of invalid user IDs."));
}
protected function Executed(CallData arguments, EPlayer instigator)

Loading…
Cancel
Save