diff options
| author | Michael <[email protected]> | 2017-07-29 13:42:25 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-07-29 13:42:25 -0400 |
| commit | 20ab7710cdf79adf7a2cff107b9ebdfe3b97633c (patch) | |
| tree | d455d3f3b9b5b498c176d7d44d19bc84a4f8b383 /ShiftOS_TheReturn | |
| parent | cc16e343b592e0855b5d3a808fcad2e4126f7068 (diff) | |
| download | shiftos_thereturn-20ab7710cdf79adf7a2cff107b9ebdfe3b97633c.tar.gz shiftos_thereturn-20ab7710cdf79adf7a2cff107b9ebdfe3b97633c.tar.bz2 shiftos_thereturn-20ab7710cdf79adf7a2cff107b9ebdfe3b97633c.zip | |
Intrinsic id parsing for terminal
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/CommandParser.cs | 42 |
1 files changed, 28 insertions, 14 deletions
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 @@ -13,17 +13,6 @@ using System.Windows.Forms; namespace ShiftOS.Engine { /// <summary> - /// Static abstraction layer for the current command parser - /// </summary> - public static class CurrentCommandParser - { - /// <summary> - /// The current parser - /// </summary> - public static CommandParser parser; - } - - /// <summary> /// Provides functionality for parsing a Terminal command string /// </summary> public sealed class CommandParser @@ -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) { |
