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) protected function BuildData(CommandDataBuilder builder)
{ {
builder.Name(P("help")).Group(P("core")) builder.Name(P("help"));
.Summary(P("Displays detailed information about available commands.")); builder.Group(P("core"));
builder.OptionalParams() builder.Summary(P("Displays detailed information about available commands."));
.ParamTextList(P("commands")) builder.OptionalParams();
.Describe(P("Displays information about all specified commands.")); builder.ParamTextList(P("commands"));
builder.Option(P("aliases"))
.Describe(P("When displaying available commands, specifying this flag" builder.Option(P("aliases"));
@ "will additionally make command to display all of their available" builder.Describe(P("When displaying available commands, specifying this flag will additionally"
@ "aliases.")) @ "make command to display all of their available aliases."));
.Option(P("list"))
.Describe(P("Display available commands. Optionally command groups can" builder.Option(P("list"));
@ "be specified and then only commands from such groups will be" builder.Describe(P("Display available commands. Optionally command groups can be specified and"
@ "listed. Otherwise all commands will be displayed.")) @ "then only commands from such groups will be listed. Otherwise all commands will"
.OptionalParams() @ "be displayed."));
.ParamTextList(P("groups")); builder.OptionalParams();
builder.ParamTextList(P("groups"));
} }
protected function Executed(Command.CallData callData, EPlayer callerPlayer) 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) protected function BuildData(CommandDataBuilder builder)
{ {
builder.ParamObject(P("just_obj")) builder.ParamObject(P("just_obj"));
.ParamArrayList(P("manyLists")) builder.ParamArrayList(P("manyLists"));
.OptionalParams() builder.OptionalParams();
.ParamObject(P("last_obj")); builder.ParamObject(P("last_obj"));
builder.SubCommand(P("simple"))
.ParamBooleanList(P("isItSimple?")) builder.SubCommand(P("simple"));
.ParamInteger(P("integer variable"), P("int")) builder.ParamBooleanList(P("isItSimple?"));
.OptionalParams() builder.ParamInteger(P("integer variable"), P("int"));
.ParamNumberList(P("numeric list"), P("list")) builder.OptionalParams();
.ParamTextList(P("another list")); builder.ParamNumberList(P("numeric list"), P("list"));
builder.ParamTextList(P("another list"));
} }
defaultproperties defaultproperties

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

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

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

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

103
sources/Users/ACommandUserGroups.uc

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

Loading…
Cancel
Save