PowerArgs.ArgParser.ParseKey C# (CSharp) Method

ParseKey() static private method

static private ParseKey ( string cmdLineArg ) : string
cmdLineArg string
return string
        internal static string ParseKey(string cmdLineArg)
        {
            if (cmdLineArg.StartsWith("/"))
            {
                var param = ParseSlashExplicitOption(cmdLineArg);
                return param.Key;
            }
            else if (cmdLineArg.StartsWith("-"))
            {
                string key = cmdLineArg.Substring(1);
                if (key.Length == 0) throw new ArgException("Missing argument value after '-'");

                // Handles long form syntax --argName=argValue.
                if (key.StartsWith("-") && key.Contains("="))
                {
                    var index = key.IndexOf("=");
                    key = key.Substring(0, index);
                }

                return key;
            }
            else
            {
                throw new ArgException("Could not parse key '"+cmdLineArg+"' because it did not start with a - or a /");
            }
        }