aboutsummaryrefslogtreecommitdiff
path: root/cli/README.md
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2020-05-12 22:48:33 +0200
committerGravatar GitHub <noreply@github.com> 2020-05-12 22:48:33 +0200
commit058d13de7014994eb136f28022c24ac6e0f3e6c2 (patch)
treef3364fc26db7efcfc273a46974833f7199dcf02c /cli/README.md
parentdf9c0ae6f1bad8ccbb9eb47b95b8d982fc74e627 (diff)
CLI user-info JSON option (#2968)
* CLI user-info JSON option Add a JSON user-info output https://github.com/FreshRSS/FreshRSS/issues/2967#issuecomment-627441744 * Uses ISO Zulu time * Typo
Diffstat (limited to 'cli/README.md')
-rw-r--r--cli/README.md20
1 files changed, 17 insertions, 3 deletions
diff --git a/cli/README.md b/cli/README.md
index a4d70b779..5a6ca75fa 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -61,9 +61,10 @@ cd /usr/share/FreshRSS
./cli/list-users.php
# Return a list of users, with the default/admin user first
-./cli/user-info.php -h --header --user username1 --user username2 ...
+./cli/user-info.php [ -h --header --json --user username1 --user username2 ... ]
# -h is to use a human-readable format
# --header outputs some columns headers
+# --json JSON format (disables --header and -h but uses ISO Zulu format for dates)
# --user indicates a username, and can be repeated
# Returns: 1) a * if the user is admin, 2) the name of the user,
# 3) the date/time of last user action, 4) the size occupied,
@@ -110,7 +111,7 @@ Now, cron will send you an email only if the exit code is non-zero and with the
## Unix piping
It is possible to invoke a command multiple times, e.g. with different usernames, thanks to the `xargs -n1` command.
-Example showing user information for all users which username starts with 'a':
+Example showing user information for all users which username starts with ‘a’:
```sh
./cli/list-users.php | grep '^a' | xargs -n1 ./cli/user-info.php -h --user
@@ -119,15 +120,28 @@ Example showing user information for all users which username starts with 'a':
Example showing all users ranked by date of last activity:
```sh
-./cli/user-info.php -h --user '*' | sort -k2 -r
+./cli/user-info.php -h | sort -k2 -r
```
Example to get the number of feeds of a given user:
```sh
./cli/user-info.php --user alex | cut -f6
+#or
+./cli/user-info.php --user alex --json | jq '.[] | .feeds'
```
+Example to get the name of the users who have not been active since a given date:
+
+```sh
+cli/user-info.php --json | jq '.[] | select(.last_user_activity < "2020-05-01") | .user'
+```
+
+Example to get the date and name of users who have not been active the past 24 hours (86400 seconds):
+
+```sh
+cli/user-info.php --json | jq -r '.[] | select((.last_user_activity | fromdate) < (now - 86400)) | [.last_user_activity, .user] | @csv'
+```
# Install and updates