From 673b6e48b0af5f2f6f92c501f82fe10281dbf20f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 5 Aug 2017 18:27:47 +0200 Subject: Mutualise create-user and update-user --- cli/_update-or-create-user.php | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 cli/_update-or-create-user.php (limited to 'cli/_update-or-create-user.php') diff --git a/cli/_update-or-create-user.php b/cli/_update-or-create-user.php new file mode 100644 index 000000000..951e28fa2 --- /dev/null +++ b/cli/_update-or-create-user.php @@ -0,0 +1,51 @@ + strParam('language'), + 'mail_login' => strParam('email'), + 'token' => strParam('token'), + 'old_entries' => intParam('purge_after_months'), + 'keep_history_default' => intParam('feed_min_articles_default'), + 'ttl_default' => intParam('feed_ttl_default'), + 'since_hours_posts_per_rss' => intParam('since_hours_posts_per_rss'), + 'min_posts_per_rss' => intParam('min_posts_per_rss'), + 'max_posts_per_rss' => intParam('max_posts_per_rss'), + ); -- cgit v1.2.3 From 5d4e4a8dd0702e42088bd93dca2158a3cb05b7a4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 5 Aug 2017 23:10:02 +0200 Subject: Fix script name in usage --- cli/_update-or-create-user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cli/_update-or-create-user.php') diff --git a/cli/_update-or-create-user.php b/cli/_update-or-create-user.php index 951e28fa2..45bfee2cf 100644 --- a/cli/_update-or-create-user.php +++ b/cli/_update-or-create-user.php @@ -23,7 +23,7 @@ if (!$isUpdate) { $options = getopt('', $params); if (empty($options['user'])) { - fail('Usage: ' . basename(__FILE__) . " --user username ( --password 'password' --api_password 'api_password'" . + fail('Usage: ' . basename($_SERVER['SCRIPT_FILENAME']) . " --user username ( --password 'password' --api_password 'api_password'" . " --language en --email user@example.net --token 'longRandomString'" . ($isUpdate ? '' : '--no_default_feeds') . " --purge_after_months 3 --feed_min_articles_default 50 --feed_ttl_default 3600" . -- cgit v1.2.3 From d0281a9f35fa5d4c607bac26ebabd43da6eb2ce2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 19 Aug 2017 16:19:03 +0200 Subject: typo update-or-create-user --- cli/_update-or-create-user.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cli/_update-or-create-user.php') diff --git a/cli/_update-or-create-user.php b/cli/_update-or-create-user.php index 45bfee2cf..c7f1008cd 100644 --- a/cli/_update-or-create-user.php +++ b/cli/_update-or-create-user.php @@ -31,10 +31,12 @@ if (empty($options['user'])) { } function strParam($name) { + global $options; return isset($options[$name]) ? strval($options[$name]) : null; } function intParam($name) { + global $options; return isset($options[$name]) && ctype_digit($options[$name]) ? intval($options[$name]) : null; } @@ -49,3 +51,5 @@ $values = array( 'min_posts_per_rss' => intParam('min_posts_per_rss'), 'max_posts_per_rss' => intParam('max_posts_per_rss'), ); + +$values = array_filter($values); -- cgit v1.2.3