From 783cff41984fec399215daafe374c852a00bfb84 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Thu, 3 Feb 2011 19:13:17 +0100
Subject: [PATCH] only one profile loaded at a time

---
 README     | 10 ++++------
 bin/cc-cli | 27 +++++++++------------------
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/README b/README
index 21444af..1ce3648 100644
--- a/README
+++ b/README
@@ -17,12 +17,10 @@ Loading
 =======
 Configuration is loaded in this order:
 1 Check CC_DEBUG, to set early debugging mode
-2 load [cli] profile in ~/.config/cc-cli/profile
-3 load profile specified by option profile in [cli] profile
-4 load profile specified by environment
-5 load profile specified on command line
-6 load options from environment
-7 load options from command line
+2 load [cli] profile from ~/.config/cc-cli/profile
+3 load profile specified by option profile (arg line, env, cli profile)
+4 load options from environment
+5 load options from command line
 
 ===========
 Environment
diff --git a/bin/cc-cli b/bin/cc-cli
index 60f2b8d..14f11f7 100755
--- a/bin/cc-cli
+++ b/bin/cc-cli
@@ -77,25 +77,16 @@ try:
         # load default profile
         if fparser.has_section("cli"):
             settings.update(fparser.items("cli"))
-        # load next profile from cli profile
-        if "profile" in settings:
-            if fparser.has_section(settings["profile"]):
-                settings.update(fparser.items(settings["profile"]))
-                del settings["profile"]
-            else:
-                printer.warn("Unable to load profile %s"%settings["profile"])
-        # load env profile
-        if "CC_PROFILE" in os.environ:
-            if fparser.has_section(os.environ["CC_PROFILE"]):
-                settings.update(fparser.items(os.environ["CC_PROFILE"]))
-            else:
-                printer.warn("Unable to load profile %s"%os.environ["CC_PROFILE"])
-        # load argline profile
+        # choose next profile to load
         if options.profile:
-            if fparser.has_section(options.profile):
-                settings.update(fparser.items(options.profile))
-            else:
-                printer.warn("Unable to load profile %s"%options.profile)
+            settings["profile"] = options.profile
+        elif "CC_PROFILE" in os.environ:
+            settings["profile"] = os.environ["CC_PROFILE"]
+        # load next profile
+        if fparser.has_section(settings["profile"]):
+            settings.update(fparser.items(settings["profile"]))
+        else:
+            printer.warn("Unable to load profile %s"%settings["profile"])
     except Exception as e:
         if cccli.debug:
             raise
-- 
GitLab