Last change
on this file since 402 was 402, checked in by alloc, 22 months ago |
- Major refactoring
- Using Utf8Json for (de)serialization
- Moving APIs to REST
- Removing dependencies from WebServer and MapRenderer to ServerFixes
|
File size:
1.3 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using JetBrains.Annotations;
|
---|
4 |
|
---|
5 | namespace CommandExtensions.Commands {
|
---|
6 | [UsedImplicitly]
|
---|
7 | public class ListItems : ConsoleCmdAbstract {
|
---|
8 | public override string GetDescription () {
|
---|
9 | return "lists all items that contain the given substring";
|
---|
10 | }
|
---|
11 |
|
---|
12 | public override string[] GetCommands () {
|
---|
13 | return new[] {"listitems", "li"};
|
---|
14 | }
|
---|
15 |
|
---|
16 | public override string GetHelp () {
|
---|
17 | return "List all available item names\n" +
|
---|
18 | "Usage:\n" +
|
---|
19 | " 1. listitems <searchString>\n" +
|
---|
20 | " 2. listitems *\n" +
|
---|
21 | "1. List only names that contain the given string.\n" +
|
---|
22 | "2. List all names.";
|
---|
23 | }
|
---|
24 |
|
---|
25 | public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) {
|
---|
26 | if (_params.Count != 1 || _params [0].Length == 0) {
|
---|
27 | SdtdConsole.Instance.Output ("Usage: listitems <searchString>");
|
---|
28 | return;
|
---|
29 | }
|
---|
30 |
|
---|
31 | int count = ItemClass.ItemNames.Count;
|
---|
32 | bool showAll = _params [0].Trim ().Equals ("*");
|
---|
33 |
|
---|
34 | int listed = 0;
|
---|
35 | for (int i = 0; i < count; i++) {
|
---|
36 | string s = ItemClass.ItemNames [i];
|
---|
37 | if (!showAll && s.IndexOf (_params [0], StringComparison.OrdinalIgnoreCase) < 0) {
|
---|
38 | continue;
|
---|
39 | }
|
---|
40 |
|
---|
41 | SdtdConsole.Instance.Output ($" {s}");
|
---|
42 | listed++;
|
---|
43 | }
|
---|
44 |
|
---|
45 | SdtdConsole.Instance.Output ($"Listed {listed} matching items.");
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.