Example #1
0
        public static Parameterdata InterpretCommandLine(string[] args)
        {
            Parameterdata ret = new Parameterdata();
            Command.ComandManager CManager = new Command.ComandManager();
            if (args.Length <= 0)
            {
                return ret;
            }
            int idx;
            foreach (string arg in args)
            {
                if (arg != null)
                {
                    if (CManager.IsStringKeyWord(arg))
                    {
                        Command.ReturnData data = CManager.ExecuteReturner(String.Join(" ", args));
                        if (data.HasData)
                        {
                            return InterpretCommandLine(((Parameterdata)data.Data).Arguments.ToArray());
                        }
                        break;
                    }
                    else if (arg[0] == '/' || arg[0] == '-' || arg[0] == '?')
                    {
                        idx = arg.Contains(':') ? arg.IndexOf(':') : arg.Contains('=') ? arg.IndexOf('=') : -1;

                        if (idx >= 0)
                        {
                            string key = arg.Substring(1, idx - 1);
                            ret.Add(key, arg.Substring(idx + 1));
                        }
                        else
                        {
                            string key = arg.Substring(1);
                            ret.Add(key, true);
                        }
                    }
                }
            }
            return ret;
        }
Example #2
0
        public static Parameterdata InterpretCommandLine(string[] args)
        {
            Parameterdata ret = new Parameterdata();
            if (args.Length <= 0)
            {
                return ret;
            }
            int idx;
            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];
                if (!String.IsNullOrEmpty(arg.Trim()))
                {
                    if (arg.StartsWith("--"))
                    {
                        arg = arg.Remove(0, 1);
                    }
                    int first = 0;
                    if (arg[0] == '/' || arg[0] == '-' || arg[0] == '?')
                    {
                        first = 1;
                    }
                    idx = arg.Contains(':') ? arg.IndexOf(':') : arg.Contains('=') ? arg.IndexOf('=') : -1;

                    if (idx >= 0)
                    {
                        string key = arg.Substring(first, idx - first);
                        ret.Add(key, arg.Substring(idx + 1));
                    }
                    else
                    {
                        string key = arg.Substring(first);
                        ret.Add(key, true);
                    }
                }
            }
            return ret;
        }