diff options
| author | 2019-03-19 20:27:06 +0100 | |
|---|---|---|
| committer | 2019-03-19 20:27:06 +0100 | |
| commit | 71b4226dc721bc0f23cc594760329f29e51defac (patch) | |
| tree | 7a90f25cd21e882b64cd6ed31f646226d80307b3 /cli/export-zip-for-user.php | |
| parent | 834ffacce22ff6a2c0f1459476dc4a45e8ea06f9 (diff) | |
Add an option validation on cli commands (#2278)
If an option used on cli is not recognized, the command
aborts and displays an error message.
If the typed option is similar to one of the recognized
options, a hint is displayed.
At the moment, there is a limitation on long options.
Short options are not validated at the moment.
See #2046
Diffstat (limited to 'cli/export-zip-for-user.php')
| -rwxr-xr-x | cli/export-zip-for-user.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cli/export-zip-for-user.php b/cli/export-zip-for-user.php index 86113d9fa..b89a55104 100755 --- a/cli/export-zip-for-user.php +++ b/cli/export-zip-for-user.php @@ -2,12 +2,14 @@ <?php require(__DIR__ . '/_cli.php'); -$options = getopt('', array( - 'user:', - 'max-feed-entries:', - )); +$params = array( + 'user:', + 'max-feed-entries:', +); -if (empty($options['user'])) { +$options = getopt('', $params); + +if (!validateOptions($argv, $params) || empty($options['user'])) { fail('Usage: ' . basename(__FILE__) . " --user username ( --max-feed-entries 100 ) > /path/to/file.zip"); } |
