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); }
public StartUp(CmdOption cmdOption) { CmdOption = cmdOption; }
/// <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); }
/// <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); }