From 058d13de7014994eb136f28022c24ac6e0f3e6c2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 12 May 2020 22:48:33 +0200 Subject: 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 --- cli/README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'cli/README.md') 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 -- cgit v1.2.3