private void HandleParsingErrorsInHelp(HelpText help) { if (this.LastPostParsingState.Errors.Count > 0) { var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces if (!string.IsNullOrEmpty(errors)) { help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):")); help.AddPreOptionsLine(errors); } } }
public string GetUsage() { var help = new HelpText { Heading = "EventStore.Client", AddDashesToOption = true }; HandleParsingErrorsInHelp(help); help.AddPreOptionsLine("Usage: EventStore.Client -i 127.0.0.1 -t 1113 -h 2113"); help.AddOptions(this); return help; }
public static void DefaultParsingErrorsHandler(CommandLineOptionsBase options, HelpText current) { if (options.InternalLastPostParsingState.Errors.Count > 0) { var errors = current.RenderParsingErrorsText(options, 2); // indent with two spaces if (!string.IsNullOrEmpty(errors)) { current.AddPreOptionsLine(string.Concat(Environment.NewLine, current.SentenceBuilder.ErrorsHeadingText)); //current.AddPreOptionsLine(errors); var lines = errors.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (var line in lines) { current.AddPreOptionsLine(line); } } } }
/* public string FullText { get { if (string.IsNullOrEmpty(_fullText)) { if (!string.IsNullOrEmpty(_line1)) { var builder = new StringBuilder(_line1); builder.AppendLineIfNotNullOrEmpty(_line2); builder.AppendLineIfNotNullOrEmpty(_line3); builder.AppendLineIfNotNullOrEmpty(_line4); builder.AppendLineIfNotNullOrEmpty(_line5); _fullText = builder.ToString(); } } return _fullText; } } */ internal void AddToHelpText(HelpText helpText, bool before) { if (before) { if (!string.IsNullOrEmpty(_line1)) helpText.AddPreOptionsLine(_line1); if (!string.IsNullOrEmpty(_line2)) helpText.AddPreOptionsLine(_line2); if (!string.IsNullOrEmpty(_line3)) helpText.AddPreOptionsLine(_line3); if (!string.IsNullOrEmpty(_line4)) helpText.AddPreOptionsLine(_line4); if (!string.IsNullOrEmpty(_line5)) helpText.AddPreOptionsLine(_line5); } else { if (!string.IsNullOrEmpty(_line1)) helpText.AddPostOptionsLine(_line1); if (!string.IsNullOrEmpty(_line2)) helpText.AddPostOptionsLine(_line2); if (!string.IsNullOrEmpty(_line3)) helpText.AddPostOptionsLine(_line3); if (!string.IsNullOrEmpty(_line4)) helpText.AddPostOptionsLine(_line4); if (!string.IsNullOrEmpty(_line5)) helpText.AddPostOptionsLine(_line5); } }