Skip to content

Commit

Permalink
Improved console feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Donkie committed Dec 24, 2019
1 parent 4c33821 commit 9dae58f
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions I3DShapesTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NDesk.Options;
using ByteSizeLib;
using NLog;
using NLog.Layouts;

namespace I3DShapesTool
{
Expand Down Expand Up @@ -51,7 +53,21 @@ private static void ShowHelp(OptionSet p)
{
Logger.Info("Usage: I3DShapesTool [-dhv --out=outPath] [-b] inFile");
Logger.Info("Extract model data from GIANTS engine's .i3d.shapes files.");
p.WriteOptionDescriptions(Console.Out);

string optionDescriptions;
using (var ms = new MemoryStream())
{
using (var tw = new StreamWriter(ms, Encoding.ASCII))
{
p.WriteOptionDescriptions(tw);
}
optionDescriptions = Encoding.ASCII.GetString(ms.ToArray());
}

foreach (var s in optionDescriptions.Split('\n'))
{
Logger.Info(s);
}
}

public static int Verbosity;
Expand All @@ -66,6 +82,7 @@ private static void SetupLogging()
var config = new NLog.Config.LoggingConfiguration();

var logconsole = new NLog.Targets.ConsoleTarget("logConsole");
logconsole.Layout = new SimpleLayout("[${level:uppercase=true}] ${message}");

LogLevel minLevel;
if (Verbosity >= 2)
Expand All @@ -82,6 +99,8 @@ private static void SetupLogging()

private static void Main(string[] args)
{
SetupLogging();

bool showHelp = false;

OptionSet p = new OptionSet
Expand Down Expand Up @@ -140,16 +159,17 @@ private static void Main(string[] args)

if (showHelp)
{
Logger.Info("This program needs to be run from a batch file or Windows command line.");
ShowHelp(p);
Logger.Info("Press enter to exit...");
Console.Read();
return;
}

SetupLogging();

ExtractFile();

Logger.Info("Done");
Logger.Info("Press enter to exit...");
Console.Read();

LogManager.Shutdown();
Expand Down

0 comments on commit 9dae58f

Please sign in to comment.