コード例 #1
0
        public override void Parse(ArgsIterator iter)
        {
            if (!iter.HasNext())
            {
                throw new CommandLineException("Filename expected");
            }

            m_fileName = iter.Next();
        }
コード例 #2
0
        public void Parse(String[] args)
        {
            ArgsIterator iter = new ArgsIterator(args);

            while (iter.HasNext())
            {
                String arg = iter.Next();
                if (arg.StartsWith("--"))
                {
                    String longParam = arg.Substring(2);
                    if (longParam.Length == 0)
                    {
                        throw new CommandLineException("Long param expected");
                    }

                    CommandLineEntry entry = FindEntry(longParam, false);
                    if (entry == null)
                    {
                        throw new CommandLineException("Unknown param: " + arg);
                    }

                    entry.Parse(iter);
                }
                else if (arg.StartsWith("-"))
                {
                    String shortParam = arg.Substring(1);
                    if (shortParam.Length == 0)
                    {
                        throw new CommandLineException("Short param expected");
                    }

                    CommandLineEntry entry = FindEntry(shortParam, true);
                    if (entry == null)
                    {
                        throw new CommandLineException("Unknown param: " + arg);
                    }

                    entry.Parse(iter);
                }
                else
                {
                    if (m_defaultEntry == null)
                    {
                        throw new CommandLineException("Default entry is not set");
                    }

                    m_defaultEntry.Parse(iter);
                }
            }
        }
コード例 #3
0
        public void Parse(String[] args)
        {
            ArgsIterator iter = new ArgsIterator(args);
            while (iter.HasNext())
            {
                String arg = iter.Next();
                if (arg.StartsWith("--"))
                {
                    String longParam = arg.Substring(2);
                    if (longParam.Length == 0)
                    {
                        throw new CommandLineException("Long param expected");
                    }

                    CommandLineEntry entry = FindEntry(longParam, false);
                    if (entry == null)
                    {
                        throw new CommandLineException("Unknown param: " + arg);
                    }

                    entry.Parse(iter);
                }
                else if (arg.StartsWith("-"))
                {
                    String shortParam = arg.Substring(1);
                    if (shortParam.Length == 0)
                    {
                        throw new CommandLineException("Short param expected");
                    }

                    CommandLineEntry entry = FindEntry(shortParam, true);
                    if (entry == null)
                    {
                        throw new CommandLineException("Unknown param: " + arg);
                    }

                    entry.Parse(iter);
                }
                else
                {
                    if (m_defaultEntry == null)
                    {
                        throw new CommandLineException("Default entry is not set");
                    }

                    m_defaultEntry.Parse(iter);
                }
            }
        }
コード例 #4
0
 public abstract void Parse(ArgsIterator iter);
コード例 #5
0
 public abstract void Parse(ArgsIterator iter);