44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
|
|
using Qrakhen.Qamp.Core;
|
|
using Qrakhen.Qamp.Core.Execution;
|
|
using Qrakhen.Qamp.Core.Tokenization;
|
|
using System.Text;
|
|
|
|
class C
|
|
{
|
|
void X()
|
|
{
|
|
ConsoleCode code = ConsoleCode.Exit;
|
|
Runner runner = new Runner(new Options());
|
|
ConsoleWriter cli = new ConsoleWriter(Encoding.Default);
|
|
do {
|
|
try {
|
|
code = cli.Read(out Stream? stream);
|
|
if (code == ConsoleCode.OK) {
|
|
if (stream == null)
|
|
throw new QampException($"Stream from CLI was null {code}");
|
|
Console.WriteLine();
|
|
runner.Run(stream);
|
|
}
|
|
if (code == ConsoleCode.Error)
|
|
throw new QampException($"CLI returned {code}");
|
|
|
|
} catch (QampException e) {
|
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
Console.WriteLine($" !> {e.Message}");
|
|
if (e.StackTrace != null) {
|
|
Console.Write($" ! ");
|
|
Console.WriteLine(string.Join("\n ! ", e.StackTrace.Split('\n')));
|
|
}
|
|
} catch (Exception e) {
|
|
Console.ForegroundColor = ConsoleColor.DarkRed;
|
|
Console.WriteLine($" !? {e.Message}");
|
|
if (e.StackTrace != null) {
|
|
Console.Write($" ! ");
|
|
Console.WriteLine(string.Join("\n ! ", e.StackTrace.Split('\n')));
|
|
}
|
|
}
|
|
} while (code != ConsoleCode.Exit);
|
|
}
|
|
}
|