Beispiel #1
0
        public List <MessageStructure> GetHelp(bool highlight = false)
        {
            var retVal = new List <MessageStructure>();
            var attr   = GlobalSettings.AvailableCmd.Where(a => a.ModuleName == ModuleName && a.CommandName == CommandName).Select(a => a.Attr).FirstOrDefault();

            if (attr == null || string.IsNullOrWhiteSpace(attr.HelpText))
            {
                retVal.Add(new MessageStructure("No help information provided.", highlight ? MessageType.ERROR : MessageType.INFO));
            }
            else
            {
                retVal.Add(new MessageStructure(attr.HelpText, highlight ? MessageType.ERROR : MessageType.INFO));
            }
            if (attr != null && !string.IsNullOrWhiteSpace(attr.ParameterOptionClass))
            {
                var module = Assembly.GetTypes().Where(t => string.Equals(t.Namespace, GlobalSettings.MouldeNameSpace, StringComparison.Ordinal) && t.Name == attr.ParameterOptionClass).FirstOrDefault();
                if (module != null)
                {
                    CmdOption instance = (CmdOption)Activator.CreateInstance(module);
                    retVal.Add(instance.GetUsage());
                }
            }
            return(retVal);
        }
Beispiel #2
0
 public StartUp(CmdOption cmdOption)
 {
     CmdOption = cmdOption;
 }
Beispiel #3
0
 /// <summary>
 /// Registers an option that takes a value.
 /// </summary>
 public CommandLine Option(string name, Action <string> parse, string description)
 {
     _options[name] = new CmdOption(name, true, parse, description);
     return(this);
 }
Beispiel #4
0
 /// <summary>
 /// Registers an option that does not take a value.
 /// </summary>
 public CommandLine Option(string name, Action action, string description)
 {
     _options[name] = new CmdOption(name, false, s => action(), description);
     return(this);
 }