Browse Source

Console command to refresh all feeds once; fixes #147

J. King 2 weeks ago
parent
commit
5efef2c2d0
3 changed files with 23 additions and 4 deletions
  1. 5
    1
      CHANGELOG
  2. 8
    3
      lib/CLI.php
  3. 10
    0
      tests/cases/CLI/TestCLI.php

+ 5
- 1
CHANGELOG View File

@@ -1,8 +1,12 @@
1
-Version 0.7.0 (2019-??-??)
1
+Version 0.7.0 (2019-03-02)
2 2
 ==========================
3 3
 
4 4
 New features:
5 5
 - Support for basic freeform searching in Tiny Tiny RSS
6
+- Console command to refresh all stale feeds once then exit
7
+
8
+Bug fixes:
9
+- Ensure updating does not fail with newsfeeds larger than 250 entries
6 10
 
7 11
 Version 0.6.1 (2019-01-23)
8 12
 ==========================

+ 8
- 3
lib/CLI.php View File

@@ -12,6 +12,7 @@ class CLI {
12 12
     const USAGE = <<<USAGE_TEXT
13 13
 Usage:
14 14
     arsse.php daemon
15
+    arsse.php feed refresh-all
15 16
     arsse.php feed refresh <n>
16 17
     arsse.php conf save-defaults [<file>]
17 18
     arsse.php user [list]
@@ -23,8 +24,8 @@ Usage:
23 24
     arsse.php --help | -h
24 25
 
25 26
 The Arsse command-line interface currently allows you to start the refresh
26
-daemon, refresh a specific feed by numeric ID, manage users, or save default
27
-configuration to a sample file.
27
+daemon, refresh all feeds or a specific feed by numeric ID, manage users,
28
+or save default configuration to a sample file.
28 29
 USAGE_TEXT;
29 30
 
30 31
     protected function usage($prog): string {
@@ -58,7 +59,7 @@ USAGE_TEXT;
58 59
             'help' => false,
59 60
         ]);
60 61
         try {
61
-            switch ($this->command(["--help", "--version", "daemon", "feed refresh", "conf save-defaults", "user"], $args)) {
62
+            switch ($this->command(["--help", "--version", "daemon", "feed refresh", "feed refresh-all", "conf save-defaults", "user"], $args)) {
62 63
                 case "--help":
63 64
                     echo $this->usage($argv0).\PHP_EOL;
64 65
                     return 0;
@@ -72,6 +73,10 @@ USAGE_TEXT;
72 73
                 case "feed refresh":
73 74
                     $this->loadConf();
74 75
                     return (int) !Arsse::$db->feedUpdate((int) $args['<n>'], true);
76
+                case "feed refresh-all":
77
+                    $this->loadConf();
78
+                    $this->getService()->watch(false);
79
+                    return 0;
75 80
                 case "conf save-defaults":
76 81
                     $file = $args['<file>'];
77 82
                     $file = ($file === "-" ? null : $file) ?? "php://output";

+ 10
- 0
tests/cases/CLI/TestCLI.php View File

@@ -74,6 +74,16 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
74 74
         Phake::verify($this->cli)->getService;
75 75
     }
76 76
 
77
+    public function testRefreshAllFeeds() {
78
+        $srv = Phake::mock(Service::class);
79
+        Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable);
80
+        Phake::when($this->cli)->getService->thenReturn($srv);
81
+        $this->assertConsole($this->cli, "arsse.php feed refresh-all", 0);
82
+        $this->assertLoaded(true);
83
+        Phake::verify($srv)->watch(false);
84
+        Phake::verify($this->cli)->getService;
85
+    }
86
+
77 87
     /** @dataProvider provideFeedUpdates */
78 88
     public function testRefreshAFeed(string $cmd, int $exitStatus, string $output) {
79 89
         Arsse::$db = Phake::mock(Database::class);

Loading…
Cancel
Save