private static int RunWith(ListOptions opts) { var storage = new ProfileStorage(); var output = new OutputTable(); output.AddColumns("name", "username", "hostname") .AddColumn("port", "0", OutputAlignment.Right) .AddColumns("ssl"); if (opts.Passwords) { output.AddColumn("password"); } foreach (var profile in storage.GetProfiles(opts)) { var row = output.AddRow(profile.Name, profile.UserName, profile.HostName, profile.Port, profile.Ssl); if (opts.Passwords) { row.Values.Add(profile.Password); } } output.WriteTo(Console.Out); return(0); }
private static void RunWithMessages(InfoOptions opts) { var storage = new ProfileStorage(); bool needLine = false; foreach (var profile in storage.GetProfiles(opts)) { using (var client = profile.CreateClient()) { var output = new OutputTable(); output .AddColumn(profile.Name) .AddColumn("messages", "#,##0", OutputAlignment.Right) .AddColumn("unread", "#,##0", OutputAlignment.Right); var messages = 0; var unread = 0; foreach (var ns in client.PersonalNamespaces) { foreach (var folder in client.GetFolders(ns).Where(f => f.ParentFolder.ParentFolder == null)) { OutputFolder(output, folder, ref messages, ref unread); } } output.AddSeparator(); output.AddRow(profile.UserName, messages, unread); if (needLine) { Console.WriteLine(); } else { needLine = true; } output.WriteTo(Console.Out); } } }