From d139d8a6ceeabc45f30543e66d401b10552f6d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Fri, 11 Apr 2025 15:52:19 -0700 Subject: [PATCH] feat(cli): add `-reset-feed-next-check-at` argument --- internal/cli/cli.go | 72 +++++++++++++++++++++++----------------- internal/storage/feed.go | 5 +++ miniflux.1 | 10 ++++-- 3 files changed, 55 insertions(+), 32 deletions(-) diff --git a/internal/cli/cli.go b/internal/cli/cli.go index de1aa71e..64d660d6 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -20,40 +20,42 @@ import ( ) const ( - flagInfoHelp = "Show build information" - flagVersionHelp = "Show application version" - flagMigrateHelp = "Run SQL migrations" - flagFlushSessionsHelp = "Flush all sessions (disconnect users)" - flagCreateAdminHelp = "Create an admin user from an interactive terminal" - flagResetPasswordHelp = "Reset user password" - flagResetFeedErrorsHelp = "Clear all feed errors for all users" - flagDebugModeHelp = "Show debug logs" - flagConfigFileHelp = "Load configuration file" - flagConfigDumpHelp = "Print parsed configuration values" - flagHealthCheckHelp = `Perform a health check on the given endpoint (the value "auto" try to guess the health check endpoint).` - flagRefreshFeedsHelp = "Refresh a batch of feeds and exit" - flagRunCleanupTasksHelp = "Run cleanup tasks (delete old sessions and archives old entries)" - flagExportUserFeedsHelp = "Export user feeds (provide the username as argument)" + flagInfoHelp = "Show build information" + flagVersionHelp = "Show application version" + flagMigrateHelp = "Run SQL migrations" + flagFlushSessionsHelp = "Flush all sessions (disconnect users)" + flagCreateAdminHelp = "Create an admin user from an interactive terminal" + flagResetPasswordHelp = "Reset user password" + flagResetFeedErrorsHelp = "Clear all feed errors for all users" + flagDebugModeHelp = "Show debug logs" + flagConfigFileHelp = "Load configuration file" + flagConfigDumpHelp = "Print parsed configuration values" + flagHealthCheckHelp = `Perform a health check on the given endpoint (the value "auto" try to guess the health check endpoint).` + flagRefreshFeedsHelp = "Refresh a batch of feeds and exit" + flagRunCleanupTasksHelp = "Run cleanup tasks (delete old sessions and archives old entries)" + flagExportUserFeedsHelp = "Export user feeds (provide the username as argument)" + flagResetNextCheckAtHelp = "Reset the next check time for all feeds" ) // Parse parses command line arguments. func Parse() { var ( - err error - flagInfo bool - flagVersion bool - flagMigrate bool - flagFlushSessions bool - flagCreateAdmin bool - flagResetPassword bool - flagResetFeedErrors bool - flagDebugMode bool - flagConfigFile string - flagConfigDump bool - flagHealthCheck string - flagRefreshFeeds bool - flagRunCleanupTasks bool - flagExportUserFeeds string + err error + flagInfo bool + flagVersion bool + flagMigrate bool + flagFlushSessions bool + flagCreateAdmin bool + flagResetPassword bool + flagResetFeedErrors bool + flagResetFeedNextCheckAt bool + flagDebugMode bool + flagConfigFile string + flagConfigDump bool + flagHealthCheck string + flagRefreshFeeds bool + flagRunCleanupTasks bool + flagExportUserFeeds string ) flag.BoolVar(&flagInfo, "info", false, flagInfoHelp) @@ -65,6 +67,7 @@ func Parse() { flag.BoolVar(&flagCreateAdmin, "create-admin", false, flagCreateAdminHelp) flag.BoolVar(&flagResetPassword, "reset-password", false, flagResetPasswordHelp) flag.BoolVar(&flagResetFeedErrors, "reset-feed-errors", false, flagResetFeedErrorsHelp) + flag.BoolVar(&flagResetFeedNextCheckAt, "reset-feed-next-check-at", false, flagResetNextCheckAtHelp) flag.BoolVar(&flagDebugMode, "debug", false, flagDebugModeHelp) flag.StringVar(&flagConfigFile, "config-file", "", flagConfigFileHelp) flag.StringVar(&flagConfigFile, "c", "", flagConfigFileHelp) @@ -190,7 +193,16 @@ func Parse() { } if flagResetFeedErrors { - store.ResetFeedErrors() + if err := store.ResetFeedErrors(); err != nil { + printErrorAndExit(err) + } + return + } + + if flagResetFeedNextCheckAt { + if err := store.ResetNextCheckAt(); err != nil { + printErrorAndExit(err) + } return } diff --git a/internal/storage/feed.go b/internal/storage/feed.go index a3f21fa9..4ccade16 100644 --- a/internal/storage/feed.go +++ b/internal/storage/feed.go @@ -485,3 +485,8 @@ func (s *Storage) ResetFeedErrors() error { _, err := s.db.Exec(`UPDATE feeds SET parsing_error_count=0, parsing_error_msg=''`) return err } + +func (s *Storage) ResetNextCheckAt() error { + _, err := s.db.Exec(`UPDATE feeds SET next_check_at=now()`) + return err +} diff --git a/miniflux.1 b/miniflux.1 index 00d2171d..0cba7ccf 100644 --- a/miniflux.1 +++ b/miniflux.1 @@ -5,8 +5,9 @@ miniflux \- Minimalist and opinionated feed reader .SH SYNOPSIS -\fBminiflux\fR [-vic] [-config-dump] [-config-file] [-create-admin] [-debug] [-flush-sessions] - [-healthcheck] [-info] [-migrate] [-refresh-feeds] [-reset-feed-errors] [-reset-password] +\fBminiflux\fR [-vic] [-config-dump] [-config-file] [-create-admin] [-debug] + [-flush-sessions] [-healthcheck] [-info] [-migrate] [-refresh-feeds] + [-reset-feed-errors] [-reset-feed-next-check-at] [-reset-password] [-run-cleanup-tasks] [-version] .SH DESCRIPTION @@ -83,6 +84,11 @@ Refresh a batch of feeds and exit\&. Clear all feed errors for all users\&. .RE .PP +.B \-reset-feed-next-check-at +.RS 4 +Reset the next check time for all feeds\&. +.RE +.PP .B \-reset-password .RS 4 Reset user password\&.