-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add the ability to support custom config files #2390
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
Conversation
|
@mgrojo I have permission to merge, but I haven't finished studying and analyzing the project source tree yet. |
mgrojo
left a comment
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.
A good start! Thanks for letting me review it.
Implement setter(setUserConfigurationFile) to store user configuration file. Move the code that print error when the argument for the option is not provided. Print detailed information when the value of an environment variable is substituted. Replaced with 'nullptr' instead of 'NULL' according to Modern C++ standard. Add code to check if provided file is a normal configuration file. Change the QSetting class object to be created only once(setSettingsObject). Using the '->' operator. Thank you so much for reviewing! @mgrojo
|
@mgrojo Thanks for the review! 😄 I modified the code according to your review.
I added a comment, but it seems that the code is like 'spaghetti code'. I'll try think about neat code continue. 👀 |
mgrojo
left a comment
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.
From a user point of view would be ready for merging, but I've made some comments regarding the code which you might want to consider.
Make QSettings* object(settings) as a static member variable. Compress error message when no arguments. Change the behavior of the 'setSettingsObject()` method to be similar to the existing interface. Simplify the normal file check code.
|
@mgrojo Thanks for the second review! 😄 I modified the code according to your review. However, calling |
Change to abort 'setSettingsObject()' if QSettings object has already been created
|
Thanks, @lucydodo. It's now merged! After merging, I've seen something that I think could be improved. If the file doesn't exist, it should be allowed and passed to |
|
@mgrojo Sorry I didn't understand what you say because my English is not very well. |
|
Sorry, I was executing another branch 😄 It works as expected, forget my comment. |
This patch changes to support custom configuration file. This PR is related to issue #2317
Two options are added for the command line:
-c [config_file]--config [config_file]We can also use environment variables without using options on the command line.
export DB4S_CONFIG_FILE=[config_file]If there is an environment variable and use the
-cor--configoption, the environment variable is ignored.Usage
Possible problem
The database file may be overwritten if the user enters only the value of the database file to be open without specifying a configuration file parameter when using this option. ->$ ./DB\ Browser\ for\ SQLite --config veryImportantDB.dbSolved through this commit(60ddbdd).
Known Bugs
If you specify an environment variable on macOS and run it with the following command, the config file is not saved anywhere.
open ./DB\ Browser\ for\ SQLite.app/However, if you specify as follows, it is saved normally.
./DB\ Browser\ for\ SQLite.app/Contents/MacOS/DB\ Browser\ for\ SQLiteTest Environment