static async Task Execute() { var client = new GitHubClient(new ProductHeaderValue("spork-client")); using var repoflector = new Repoflector(); using var nuggieflector = new Nuggieflector(); var repositories = await client.Repository.GetAllForOrg("rebus-org"); var rebusCoreVersion = (await nuggieflector.GetVersions("Rebus")).Last(); Console.WriteLine("Loading repositories..."); async Task <List <Dictionary <string, object> > > GetRows() { using var _ = new IndefiniteSpinner(); return(await GenerateReportCommand.GetRows(repositories, repoflector, nuggieflector, rebusCoreVersion)); } var rows = await GetRows(); Console.WriteLine(Formatter.FormatDictionaries(rows)); }
public void CanUseDictionaryAsInput() { var tableFormatter = new TableFormatter(); var text = tableFormatter.FormatDictionaries(new[] { new Dictionary <string, string> { { "Headline with space", "Some value" } }, new Dictionary <string, string> { { "Headline with space", "Another value" } }, new Dictionary <string, string> { { "Another headline with space", "Third value" } }, new Dictionary <string, string> { { "Yet another headline with space", "Fourth value" } }, }); Console.WriteLine(text); const string expected = @" +---------------------+-----------------------------+---------------------------------+ | Headline with space | Another headline with space | Yet another headline with space | +---------------------+-----------------------------+---------------------------------+ | Some value | | | +---------------------+-----------------------------+---------------------------------+ | Another value | | | +---------------------+-----------------------------+---------------------------------+ | | Third value | | +---------------------+-----------------------------+---------------------------------+ | | | Fourth value | +---------------------+-----------------------------+---------------------------------+ "; Assert.That(text.Normalized(), Is.EqualTo(expected.Normalized())); }
private static IList <string> BuildCompareTables( Dictionary <CryptoExchange, Dictionary <CryptoExchange, Dictionary <string, decimal> > > compare) { var tables = new List <string> ( ); foreach (var from in compare) { var table = new StringBuilder( ); var formatter = new TableFormatter( ); var objects = new List <IDictionary <string, object> > ( ); table.AppendLine($"{from.Key}"); var symbols = ExtractSymbols(from); foreach (var value in from.Value) { var dict = new Dictionary <string, object> { ["Exchange"] = $"{value.Key}" }; foreach (var symbol in symbols) { dict[symbol] = value.Value.ContainsKey(symbol) ? $"{value.Value[symbol]:P}" : ""; } objects.Add(dict); } table.AppendLine(formatter.FormatDictionaries(objects)); table.AppendLine( ); tables.Add(table.ToString( )); } return(tables); }
public string GetStatusString( ) { var formatter = new TableFormatter( ); var objects = Ctb.Exchanges.Values.Select( exchange => new Dictionary <string, string> { ["Exchange"] = exchange.Name, ["Up Time"] = exchange.UpTime.Humanize(2, minUnit: TimeUnit.Second), ["Last Update"] = exchange.LastUpdateDuration.Humanize( ) } ) .Cast <IDictionary <string, string> > ( ) .ToList( ); var builder = new StringBuilder( ); builder .AppendLine( $"Running since {( DateTime.UtcNow - Ctb.StartTime ).Humanize ( 3, minUnit: TimeUnit.Second )}") .AppendLine("") .AppendLine(formatter.FormatDictionaries(objects)); return(builder.ToString( )); }
async Task Execute() { var client = new GitHubClient(new ProductHeaderValue("spork-client")); var repoflector = new Repoflector(); Using(repoflector); var nuggieflector = new Nuggieflector(); Using(nuggieflector); var repositories = await client.Repository.GetAllForOrg("rebus-org"); var rebusCoreVersion = (await nuggieflector.GetVersions("Rebus")).Last(); Console.WriteLine("Loading repositories..."); using (new IndefiniteSpinner()) { var rows = await GetRows(repositories, repoflector, nuggieflector, rebusCoreVersion); Console.WriteLine(Formatter.FormatDictionaries(rows)); } }