Rev | Line | |
---|
[128] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
[130] | 4 | namespace AllocsFixes.CustomCommands
|
---|
[128] | 5 | {
|
---|
[130] | 6 | public class ListItems : ConsoleCommand
|
---|
[128] | 7 | {
|
---|
[130] | 8 | public ListItems (ConsoleSdtd cons) : base(cons)
|
---|
| 9 | {
|
---|
| 10 | }
|
---|
[128] | 11 |
|
---|
[130] | 12 | public override string Description ()
|
---|
| 13 | {
|
---|
| 14 | return "lists all items that contain the given substring";
|
---|
| 15 | }
|
---|
[128] | 16 |
|
---|
[130] | 17 | public override string[] Names ()
|
---|
| 18 | {
|
---|
| 19 | return new string[] { "listitems", "li" };
|
---|
| 20 | }
|
---|
[128] | 21 |
|
---|
[130] | 22 | public override void Run (string[] _params)
|
---|
| 23 | {
|
---|
| 24 | try {
|
---|
| 25 | if (_params.Length != 1 || _params [0].Length == 0) {
|
---|
| 26 | m_Console.SendResult ("Usage: listitems <searchString>");
|
---|
| 27 | return;
|
---|
| 28 | }
|
---|
[128] | 29 |
|
---|
[130] | 30 | int n = 0;
|
---|
| 31 | foreach (ItemBase ib in ItemBase.list) {
|
---|
| 32 | if (ib.name != null && ib.name.ToLower ().Contains (_params [0].ToLower ())) {
|
---|
| 33 | m_Console.SendResult (" " + ib.name);
|
---|
| 34 | n++;
|
---|
| 35 | }
|
---|
[128] | 36 | }
|
---|
[130] | 37 |
|
---|
| 38 | m_Console.SendResult ("Listed " + n + " matching items.");
|
---|
| 39 | } catch (Exception e) {
|
---|
| 40 | Log.Out ("Error in ListItems.Run: " + e);
|
---|
[128] | 41 | }
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.