public void HelpNoCommands() { var o = new OnlyDefaultCommand(); var p = new CommandProviderImplementation(o); var helpMessage = TextFormatExtensions.GetWritable(_ => Amg.GetOpt.Help.PrintHelpMessage(_, p)).ToString(); Assert.Pass(helpMessage); }
IWritable PublicApi(Type t) => TextFormatExtensions.GetWritable(w => { if (!t.IsPublic) { return; } w.WriteLine(t.FullName); });
static IWritable Line <T>(IEnumerable <T> e) => TextFormatExtensions.GetWritable(w => { foreach (var i in e) { var p = GetPropertyValues(i).Select(_ => _.SafeToString()).ToArray(); w.Write(p[0]); w.Write(" : "); w.WriteLine(p[1]); } });
public void Help() { var o = new WithStandardOptions(new TestCommandObject()); var p = new CommandProviderImplementation(o); var helpMessage = TextFormatExtensions.GetWritable(_ => Amg.GetOpt.Help.PrintHelpMessage(_, p)).ToString(); Console.WriteLine(helpMessage); Assert.That(helpMessage, Does.Contain("Run a command.")); Assert.That(helpMessage, Does.Contain("Options:")); Assert.Pass(helpMessage); }
IWritable PublicApi(Assembly a) => TextFormatExtensions.GetWritable(w => { w.WriteLine(a.GetName().Name); foreach (var t in a.GetTypes() .Where(_ => _.IsPublic) .OrderBy(_ => _.FullName) ) { w.Write(PublicApi(t)); } });
static IWritable Indented <T>(IEnumerable <T> e, int indent = 2) => TextFormatExtensions.GetWritable(w => { foreach (var i in e) { var p = GetPropertyValues(i).Select(_ => _.SafeToString()).ToArray(); if (p[0].Length > indent) { w.WriteLine(p[0]); w.Write(new string(' ', indent)); w.WriteLine(p[1]); } else { w.Write(p[0]); w.Write(new string(' ', indent - p[0].Length)); w.WriteLine(p[1]); } } });