-
-
Notifications
You must be signed in to change notification settings - Fork 777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2297 cli parameters consistency #6028
2297 cli parameters consistency #6028
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested it but it seems alright. Good job.
cli/_cli.php
Outdated
/** | ||
* Parses perameters used with FreshRSS' CLI commands. | ||
* @param array{'valid':array<string,string>,'deprecated':array<string,string>} $parameters An array of 'valid': An | ||
* array of perameters as keys and their respective getopt() notations as values. 'deprecated' An array with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* array of perameters as keys and their respective getopt() notations as values. 'deprecated' An array with | |
* array of parameters as keys and their respective getopt() notations as values. 'deprecated' An array with |
There are multiple instances of parameters
. Please replace them by parameters
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't believe I forgot how to spell parameters...
Closes #2297
Changes proposed in this pull request:
We want to standardise flags used with CLI commands around the use of '-' rather than '_' while maintaining backward compatibility. To that end I've deprecated all flags using '_' in favour of an equivalent using '-' and introduced a check for the use of deprecated flags as well as logic to replace any used deprecated flags with their replacements. I've also scooped up some existing logic for CLI flag retrieval and validation and wrapped all this up into a parseCliParams() function. This way we can start to isolate some logic that otherwise is scattered throughout individual CLI commands.
If we're happy with the changes proposed here, then I could look at raising some related tickets such as extending use of parseCliParams() to other relevant CLI commands and looking at other opportunities for standardisation around validating CLI inputs as there is currently quite a bit of variation in how individual CLI commands handle similar work e.g. validating options associated with flags or updating config.
How to test the feature manually:
Use either cli/do-install, cli/reconfigure, cli/create-user or cli/update-user with updated flags (e.g. --default-user admin --allow-anonymous) to see successful behaviour.
Use deprecated flags (e.g. --default_user admin --allow_anonymous) to see successful behaviour with a deprecation warning.
Use unknown flags (e.g. --defaultuser admin --allow_anon)to trigger expected warning and failure.
Pull request checklist: