Exemplo n.º 1
0
        public void Build(BogApiClientApplication clientApplication)
        {
            var restoreCommand = clientApplication.FindCommandByName(CommandTypeNameValues.RESTORE_COMMAND);

            if (restoreCommand == null)
            {
                throw new Exception($"Could not find {CommandTypeNameValues.RESTORE_COMMAND}");
            }

            restoreCommand.Command(CreateSubCommands.ARTICLE, app =>
            {
                app.HelpOption(CommandApplicationConfigurationValues.HELP_TEMPLATE);
                app.Description = "restore an existing bog article";

                var articleId = app.Argument(CommandApplicationArgumentValues.ARTICLE_ID, CommandApplicationDescriptions.ARTICLE_ID);

                app.OnExecute(async() =>
                {
                    if (string.IsNullOrWhiteSpace(articleId.Value) || string.IsNullOrWhiteSpace(articleId.Value))
                    {
                        app.ShowHelp();
                        return(1);
                    }

                    await _restoreArticleCommand.Restore(articleId.Value);
                    return(0);
                });
            });
        }
Exemplo n.º 2
0
        public void Build(BogApiClientApplication clientApplication)
        {
            var createCommand = clientApplication.FindCommandByName(CommandTypeNameValues.CREATE_COMMAND);

            createCommand.Command(CreateSubCommands.ARTICLE, app =>
            {
                app.HelpOption(CommandApplicationConfigurationValues.HELP_TEMPLATE);
                app.Description = "create a new bog article";

                var blogId      = app.Argument(CommandApplicationArgumentValues.BLOG_ID, CommandApplicationDescriptions.BLOG_ID);
                var author      = app.Argument(CommandApplicationArgumentValues.AUTHOR, CommandApplicationDescriptions.AUTHOR);
                var title       = app.Argument(CommandApplicationArgumentValues.TITLE, CommandApplicationDescriptions.TITLE);
                var description = app.Option(CommandApplicationOptionValues.DESCRIPTION, CommandApplicationDescriptions.DESCRIPTION, CommandOptionType.SingleValue);

                app.OnExecute(async() =>
                {
                    if (string.IsNullOrWhiteSpace(blogId.Value) ||
                        string.IsNullOrWhiteSpace(author.Value) ||
                        string.IsNullOrWhiteSpace(title.Value)
                        )
                    {
                        app.ShowHelp();
                        return(1);
                    }

                    await _cmd.CreateArticle(blogId.Value, author.Value, title.Value, description.Value());
                    return(0);
                });
            });
        }
Exemplo n.º 3
0
        public void Build(BogApiClientApplication clientApplication)
        {
            var updateCommand = clientApplication.FindCommandByName(CommandTypeNameValues.UPDATE_COMMAND);

            updateCommand.Command(CreateSubCommands.MEDIA, app =>
            {
                app.HelpOption(CommandApplicationConfigurationValues.HELP_TEMPLATE);
                app.Description = "Upload all bog article entry media within the current context";

                var mediaGlobPatternArgument = app.Argument(
                    CommandApplicationArgumentValues.MEDIA_GLOB_PATTERN,
                    CommandApplicationDescriptions.MEDIA_GLOB_PATTERN,
                    (commandArg) => { commandArg.MultipleValues = true; });

                app.OnExecute(async() =>
                {
                    var mediaGlobPatterns = mediaGlobPatternArgument.Values;

                    if (mediaGlobPatternArgument.Values == null || !mediaGlobPatternArgument.Values.Any())
                    {
                        app.ShowHelp();
                        return(1);
                    }

                    await _updateMediaCommand.UpdateMediaFiles(mediaGlobPatterns.ToArray());
                    return(0);
                });
            });
        }
        public void Build(BogApiClientApplication clientApplication)
        {
            var updateCommand = clientApplication.FindCommandByName(CommandTypeNameValues.UPDATE_COMMAND);

            updateCommand.Command(CreateSubCommands.ARTICLE, app =>
            {
                app.HelpOption(CommandApplicationConfigurationValues.HELP_TEMPLATE);
                app.Description = "update a bog article within the current context";

                var author      = app.Option(CommandApplicationOptionValues.AUTHOR, CommandApplicationDescriptions.AUTHOR, CommandOptionType.SingleValue);
                var title       = app.Option(CommandApplicationOptionValues.TITLE, CommandApplicationDescriptions.TITLE, CommandOptionType.SingleValue);
                var description = app.Option(CommandApplicationOptionValues.DESCRIPTION, CommandApplicationDescriptions.DESCRIPTION, CommandOptionType.SingleValue);
                var publish     = app.Option(CommandApplicationOptionValues.PUBLISH, CommandApplicationDescriptions.PUBLISH, CommandOptionType.NoValue);
                var unPublish   = app.Option(CommandApplicationOptionValues.UNPUBLISH, CommandApplicationDescriptions.UNPUBLISH, CommandOptionType.NoValue);


                app.OnExecute(async() =>
                {
                    bool?isPublished = publish.HasValue()? true : null as bool?;
                    isPublished      = unPublish.HasValue() ? false : isPublished;
                    await _updateArticleCommand.UpdateArticle(author.Value(), title.Value(), description.Value(), isPublished);
                    return(0);
                });
            });
        }
Exemplo n.º 5
0
        public void Build(BogApiClientApplication clientApplication)
        {
            var deleteCommand = clientApplication.FindCommandByName(CommandTypeNameValues.DELETE_COMMAND);

            deleteCommand.Command(CreateSubCommands.ARTICLE, app =>
            {
                app.HelpOption(CommandApplicationConfigurationValues.HELP_TEMPLATE);
                app.Description = "mark bog article within the current context as deleted";

                app.OnExecute(async() =>
                {
                    await Task.CompletedTask;
                    await _deleteArticleCommand.MarkArticleAsDeleted();
                    return(0);
                });
            });
        }
        public void Build(BogApiClientApplication clientApplication)
        {
            var updateCommand = clientApplication.FindCommandByName(CommandTypeNameValues.UPDATE_COMMAND);

            updateCommand.Command(CreateSubCommands.ENTRY, app =>
            {
                app.HelpOption(CommandApplicationConfigurationValues.HELP_TEMPLATE);
                app.Description = "update a bog article entry within the current context";

                var entryFileName = app.Argument(CommandApplicationArgumentValues.FILE_NAME, CommandApplicationDescriptions.FILE_NAME);

                app.OnExecute(async() =>
                {
                    if (string.IsNullOrWhiteSpace(entryFileName.Value))
                    {
                        app.ShowHelp();
                        return(1);
                    }

                    await _updateEntryCommand.UpdateEntry(entryFileName.Value);
                    return(0);
                });
            });
        }
        public void Build(BogApiClientApplication clientApplication)
        {
            var updateCommand = clientApplication.FindCommandByName(CommandTypeNameValues.UPDATE_COMMAND);

            updateCommand.Command(CreateSubCommands.META_TAG, app =>
            {
                app.HelpOption(CommandApplicationConfigurationValues.HELP_TEMPLATE);
                app.Description = "update meta tags on a bog article";

                var tags = app.Argument(CommandApplicationArgumentValues.TAG, CommandApplicationDescriptions.TAG, true);

                app.OnExecute(async() =>
                {
                    if (!tags.Values.Any())
                    {
                        app.ShowHelp();
                        return(0);
                    }

                    await _updateMetaTagsCommand.UpdateMetaTags(tags.Values.ToArray());
                    return(0);
                });
            });
        }