예제 #1
0
                protected override async Task <int> OnExecuteAuthenticatedAsync(QBittorrentClient client, CommandLineApplication app, IConsole console)
                {
                    var root = await client.GetRssItemsAsync(false);

                    var doc = new Document(RenderItem(root, true, true)).SetColors(ColorScheme.Current.Normal);

                    ConsoleRenderer.RenderDocument(doc);
                    return(ExitCodes.Success);

                    Stack RenderFolderContent(RssFolder folder)
                    {
                        return(new Stack(folder.Items.Select(
                                             (item, index) => RenderItem(item, index == folder.Items.Count - 1))));
                    }

                    object RenderFeed(RssFeed feed)
                    {
                        return(new Div(
                                   feed.Name,
                                   " ",
                                   new Span($"[{feed.Url}]").SetColors(ColorScheme.Current.Inactive)));
                    }

                    Grid RenderItem(RssItem item, bool last, bool isRoot = false)
                    {
                        var folder = item as RssFolder;

                        return(new Grid
                        {
                            Columns =
                            {
                                new Column {
                                    Width = GridLength.Char(2)
                                },
                                new Column {
                                    Width = GridLength.Star(1)
                                }
                            },