One teeny tiny more thing.

This commit is contained in:
That_One_Nerd 2023-04-19 07:28:40 -04:00
parent 318c8119a0
commit 647993ef1f
2 changed files with 17 additions and 6 deletions

View File

@ -7,6 +7,7 @@ global using SrcMod.Shell.Interop;
global using SrcMod.Shell.Modules.ObjectModels; global using SrcMod.Shell.Modules.ObjectModels;
global using SrcMod.Shell.ObjectModels; global using SrcMod.Shell.ObjectModels;
global using System; global using System;
global using System.Collections;
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.ComponentModel; global using System.ComponentModel;
global using System.Diagnostics; global using System.Diagnostics;

View File

@ -1,4 +1,6 @@
namespace SrcMod.Shell.Modules; using SharpCompress;
namespace SrcMod.Shell.Modules;
[Module("config")] [Module("config")]
public static class ConfigModule public static class ConfigModule
@ -139,19 +141,27 @@ public static class ConfigModule
Write(new string(' ', indents * 4), newLine: false); Write(new string(' ', indents * 4), newLine: false);
if (!string.IsNullOrWhiteSpace(name)) Write($"{name}: ", newLine: false); if (!string.IsNullOrWhiteSpace(name)) Write($"{name}: ", newLine: false);
if (item is Array itemArray) if (item is IEnumerable itemEnumerable)
{ {
if (itemArray.Length < 1) // This is a bit inefficient.
int count = 0;
foreach (object _ in itemEnumerable) count++;
object[] itemData = new object[count];
count = 0;
foreach (object obj in itemEnumerable) itemData[count] = obj;
if (itemData.Length < 1)
{ {
Write("[]", ConsoleColor.DarkGray, newLine); Write("[]", ConsoleColor.DarkGray, newLine);
return; return;
} }
Write("[", ConsoleColor.DarkGray); Write("[", ConsoleColor.DarkGray);
for (int i = 0; i < itemArray.Length; i++) for (int i = 0; i < itemData.Length; i++)
{ {
DisplayConfigItem(itemArray.GetValue(i), indents + 1, newLine: false); DisplayConfigItem(itemData.GetValue(i), indents + 1, newLine: false);
if (i < itemArray.Length - 1) Write(',', newLine: false); if (i < itemData.Length - 1) Write(',', newLine: false);
Write('\n', newLine: false); Write('\n', newLine: false);
} }
Write(new string(' ', indents * 4) + "]", ConsoleColor.DarkGray, newLine); Write(new string(' ', indents * 4) + "]", ConsoleColor.DarkGray, newLine);