コード例 #1
0
 public string GetOption(CliOption o)
 {
     if (o == null)
     {
         throw new ArgumentNullException("o");
     }
     return(GetOption(o.DefaultValue, o.Names));
 }
コード例 #2
0
 public bool HasOption(CliOption opt)
 {
     if (opt == null)
     {
         throw new ArgumentNullException("opt");
     }
     return(HasOption(opt.Names));
 }
コード例 #3
0
        static string LeftOf(CliOption opt)
        {
            string l = string.Format("/{0}", opt.Name);

            if (!string.IsNullOrEmpty(opt.Format))
            {
                l += ":" + opt.Format;
            }
            return(l);
        }
コード例 #4
0
        public bool IsMinus(CliOption opt)
        {
            if (opt == null)
            {
                throw new ArgumentNullException("opt");
            }

            if (!opt.PlusMinus)
            {
                throw new ArgumentException(
                          string.Format("Option {0} has no [+|-] format", opt.Name), "opt");
            }

            foreach (var item in Options)
            {
                string name = item.Name;
                if (opt.CheckName(name, true))
                {
                    int nn = name.Length;
                    if (name[nn - 1] == '+')
                    {
                        return(false);
                    }
                    if (name[nn - 1] == '-')
                    {
                        return(true);
                    }
                    if (!ParseBool(item.Value, true))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }