Пример #1
0
        public void Register(CommandLineEntry entry)
        {
            String shortName = entry.ShortName;
            String longName  = entry.LongName;

            if (shortName != null)
            {
                m_shortLookup[shortName] = entry;
            }
            if (longName != null)
            {
                m_longLookup[longName] = entry;
            }
        }
Пример #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);
                }
            }
        }
 public void SetDefaultEntry(CommandLineEntry entry)
 {
     m_defaultEntry = entry;
 }
        public void Register(CommandLineEntry entry)
        {
            String shortName = entry.ShortName;
            String longName = entry.LongName;

            if (shortName != null)
            {
                m_shortLookup[shortName] = entry;
            }
            if (longName != null)
            {
                m_longLookup[longName] = entry;
            }
        }
Пример #5
0
 public void SetDefaultEntry(CommandLineEntry entry)
 {
     m_defaultEntry = entry;
 }