Пример #1
0
 /// <summary>
 /// Prompt for and get the value for the option.
 /// </summary>
 /// <param name="option">The option to prompt for.</param>
 public static void ForOption(Option option)
 {
     if (!option.Assigned && option.Prompt && CanPrompt)
     {
         if (option.Description != null)
         {
             Console.WriteLine();
             Console.WriteLine("----- {0} -----", option.Title.ToUpper());
             // Format the description.
             Regex           lineSplitter = new Regex(@".{0,50}[^\s]*");
             MatchCollection matches      = lineSplitter.Matches(option.Description);
             foreach (Match line in matches)
             {
                 Console.WriteLine(line.Value.Trim());
             }
             Console.WriteLine();
         }
         if (option.GetType() == typeof(BoolOption))
         {
             option.Value = ForYesNo(option.Title, Boolean.Parse(option.DefaultValue)).ToString();
         }
         else
         {
             option.Value = ForString(option.Title, option.DefaultValue);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Prompt for and get the value for the option.
        /// </summary>
        /// <param name="option">The option to prompt for.</param>
        public static void ForOption(Option option)
        {
            if (!option.Assigned && option.Prompt && CanPrompt)
            {
                if (option.Description != null)
                {
                    Console.WriteLine();
                    Console.WriteLine("----- {0} -----", option.Title.ToUpper());
                    // Format the description.
                    Regex           lineSplitter = new Regex(@".{0,50}[^\s]*");
                    MatchCollection matches      = lineSplitter.Matches(option.Description);
                    foreach (Match line in matches)
                    {
                        Console.WriteLine(line.Value.Trim());
                    }
                    Console.WriteLine();
                }
                if (option.GetType() == typeof(BoolOption))
                {
                    option.Value = ForYesNo(option.Title, Boolean.Parse(option.DefaultValue)).ToString();
                }
                else
                {
/********************************************************************************************************
 *              Note: This method is for Reading password with echo off,  This needs Mono runtime version
 *                     1.2.3 or later.
 *
 *                                      if(String.Compare(option.Name, "ldap-admin-password") == 0 ||
 *                                              String.Compare(option.Name, "system-admin-password") == 0 ||
 *                                              String.Compare(option.Name, "ldap-proxy-password") == 0 )
 *                                              option.Value = ForPasswordString(option.Title, option.DefaultValue);
 *                                      else
 *                                              option.Value = ForString(option.Title, option.DefaultValue);
 *
 ***********************************************************************************************************/
                    option.Value = ForString(option.Title, option.DefaultValue);
                }
            }
        }
Пример #3
0
 public static void ForOption(Option option)
 {
     if (!option.Assigned && option.Prompt && CanPrompt)
        {
     if (option.Description != null)
     {
      Console.WriteLine();
      Console.WriteLine("----- {0} -----", option.Title.ToUpper());
      Regex lineSplitter = new Regex(@".{0,50}[^\s]*");
      MatchCollection matches = lineSplitter.Matches(option.Description);
      foreach (Match line in matches)
      {
       Console.WriteLine(line.Value.Trim());
      }
      Console.WriteLine();
     }
     if (option.GetType() == typeof(BoolOption))
      option.Value = ForYesNo(option.Title, Boolean.Parse(option.DefaultValue)).ToString();
     else
      option.Value = ForString(option.Title, option.DefaultValue);
        }
 }