Last change
on this file since 338 was 325, checked in by alloc, 6 years ago |
Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 |
|
---|
4 | namespace AllocsFixes.CustomCommands {
|
---|
5 | public class ListItems : ConsoleCmdAbstract {
|
---|
6 | public override string GetDescription () {
|
---|
7 | return "lists all items that contain the given substring";
|
---|
8 | }
|
---|
9 |
|
---|
10 | public override string[] GetCommands () {
|
---|
11 | return new[] {"listitems", "li"};
|
---|
12 | }
|
---|
13 |
|
---|
14 | public override string GetHelp () {
|
---|
15 | return "List all available item names\n" +
|
---|
16 | "Usage:\n" +
|
---|
17 | " 1. listitems <searchString>\n" +
|
---|
18 | " 2. listitems *\n" +
|
---|
19 | "1. List only names that contain the given string.\n" +
|
---|
20 | "2. List all names.";
|
---|
21 | }
|
---|
22 |
|
---|
23 | public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) {
|
---|
24 | try {
|
---|
25 | if (_params.Count != 1 || _params [0].Length == 0) {
|
---|
26 | SdtdConsole.Instance.Output ("Usage: listitems <searchString>");
|
---|
27 | return;
|
---|
28 | }
|
---|
29 |
|
---|
30 | int count = ItemClass.ItemNames.Count;
|
---|
31 | bool showAll = _params [0].Trim ().Equals ("*");
|
---|
32 |
|
---|
33 | int listed = 0;
|
---|
34 | for (int i = 0; i < count; i++) {
|
---|
35 | string s = ItemClass.ItemNames [i];
|
---|
36 | if (showAll || s.IndexOf (_params [0], StringComparison.OrdinalIgnoreCase) >= 0) {
|
---|
37 | SdtdConsole.Instance.Output (" " + s);
|
---|
38 | listed++;
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | SdtdConsole.Instance.Output ("Listed " + listed + " matching items.");
|
---|
43 | } catch (Exception e) {
|
---|
44 | Log.Out ("Error in ListItems.Run: " + e);
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.