From 20ab7710cdf79adf7a2cff107b9ebdfe3b97633c Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 Jul 2017 13:42:25 -0400 Subject: Intrinsic id parsing for terminal --- ShiftOS_TheReturn/CommandParser.cs | 42 +++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/CommandParser.cs b/ShiftOS_TheReturn/CommandParser.cs index d56e7bd..bd274cd 100644 --- a/ShiftOS_TheReturn/CommandParser.cs +++ b/ShiftOS_TheReturn/CommandParser.cs @@ -12,17 +12,6 @@ using System.Windows.Forms; namespace ShiftOS.Engine { - /// - /// Static abstraction layer for the current command parser - /// - public static class CurrentCommandParser - { - /// - /// The current parser - /// - public static CommandParser parser; - } - /// /// Provides functionality for parsing a Terminal command string /// @@ -119,6 +108,8 @@ namespace ShiftOS.Engine int i = 0; string currentArgument = ""; int help = -1; + bool id_found = false; + string id_text = ""; while (position < text.Length) { @@ -131,7 +122,21 @@ namespace ShiftOS.Engine } CommandFormat part = parts[i]; - string res = part.CheckValidity(text.Substring(position)); + string inp = text.Substring(position); + string res = part.CheckValidity(inp); + if(part is CommandFormatText) + { + if(res == "+FALSE+") + { + if(id_found == false) + { + id_found = true; + id_text = inp; + res = ""; + arguments.Add("id", inp); + } + } + } // ok so: @@ -148,8 +153,17 @@ namespace ShiftOS.Engine } else if (part is CommandFormatArgument) { - currentArgument = res; - help = -1; + if (arguments.ContainsKey(res)) + { + Console.WriteLine("Duplicate command-line argument detected: " + res); + command = "+FALSE+"; + position = text.Length; + } + else + { + currentArgument = res; + help = -1; + } } else if (part is CommandFormatValue) { -- cgit v1.2.3