Repository: qutebrowser/qutebrowser
Pull request: Add --config cli option for overwriting the path to config.py
This adds a new cli flag for setting the path to config.py.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/qutebrowser/qutebrowser/4286)
<!-- Reviewable:end -->

*Edit by @The-Compiler to auto-close the issue: Fixes #4132*


Problem statement:
Add a --config-py option to specify a path to an alternate config.py
Currently, config.py is always expected to be found in <basedir>/config/config.py. However, there are many cases where it would be useful to specify the path to the config.py on the command line. For example, you may wish to use a custom config.py with ---temp-basedir, where the basedir isn't known ahead of time.

Please consider adding this functionality. It will be very useful.

Thanks.

Hints from issue discussion:
Also see #2115 / 671ce67be5bb2df6a13b408c19d8c79c76eaade4 which removed a similar `--confdir` setting - but I'm fine with just having a `--config-py` because it'd indeed be useful, and it's much more clear how it should behave (as `config.py` is read-only).
Could I start working on this?
@cauimsouza Sure, go ahead! :+1:
If I can help with that, give me a shout.

Commit message: Add spaces to make linter happy

Patch to review:
diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py
index 8480889af6a..25c645eb57f 100644
--- a/qutebrowser/config/configinit.py
+++ b/qutebrowser/config/configinit.py
@@ -55,7 +55,8 @@ def early_init(args):
         config.instance, config.key_instance)
     objreg.register('config-commands', config_commands)
 
-    config_file = os.path.join(standarddir.config(), 'config.py')
+    config_file = (args.config if args.config is not None
+                   else os.path.join(standarddir.config(), 'config.py'))
 
     try:
         if os.path.exists(config_file):
diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py
index f01bf5f180b..c6ba755fbcd 100644
--- a/qutebrowser/qutebrowser.py
+++ b/qutebrowser/qutebrowser.py
@@ -63,6 +63,7 @@ def get_argparser():
                                      description=qutebrowser.__description__)
     parser.add_argument('-B', '--basedir', help="Base directory for all "
                         "storage.")
+    parser.add_argument('-C', '--config', help="Path to config.py")
     parser.add_argument('-V', '--version', help="Show version and quit.",
                         action='store_true')
     parser.add_argument('-s', '--set', help="Set a temporary setting for "


Code review comments:
diff_hunk: @@ -63,6 +63,7 @@ def get_argparser():
                                      description=qutebrowser.__description__)
     parser.add_argument('-B', '--basedir', help="Base directory for all "
                         "storage.")
+    parser.add_argument('-C', '--config', help="Path to config.py")
path: qutebrowser/qutebrowser.py
text: @user1:
I'd prefer to call it `--config-py` so it's clear that it's only a path to a `config.py` file, not a config folder.