Repository: conda/conda

Issue:
Unable to set conda-build.root-dir with config
Not sure the right way to do this, but it looks like there might not be any right way ATM. I would like to be able to use `conda config` to get the following added to my `.condarc` file.

```yaml
conda-build:
    root-dir: /tmp
```

If I try to set `conda-build.root-dir` with `conda config`, I get this error.

```bash
$ conda config --set "conda-build.root-dir" "/tmp"


CondaValueError: Value error: Error key must be one of add_anaconda_token, shortcuts, add_pip_as_python_dependency, ssl_verify, client_tls_cert, binstar_upload, use_pip, add_binstar_token, always_copy, always_yes, client_tls_cert_key, channel_alias, changeps1, channel_priority, show_channel_urls, update_dependencies, allow_softlinks, anaconda_upload, offline, allow_other_channels, auto_update_conda, not conda-build.root-dir


```


Discussion:
cc @msarahan
`conda config --set` doesn't currently support map-type parameters.
It should be possible to do

`conda config --set proxy_servers.http 1.2.3.4:4004`

and

`conda config --get proxy_servers.http`

Resolving patch:
diff --git a/conda/cli/main_config.py b/conda/cli/main_config.py
--- a/conda/cli/main_config.py
+++ b/conda/cli/main_config.py
@@ -383,18 +383,31 @@ def execute_config(args, parser):
                     json_warnings.append(message)
             arglist.insert(0 if prepend else len(arglist), item)
 
+    primitive_parameters = frozenset(
+        p for p in context.list_parameters()
+        if context.describe_parameter(p)['parameter_type'] == 'primitive'
+    )
+    map_parameters = frozenset(
+        p for p in context.list_parameters()
+        if context.describe_parameter(p)['parameter_type'] == 'map'
+    )
+
     # Set
     for key, item in args.set:
-        primitive_parameters = [p for p in context.list_parameters()
-                                if context.describe_parameter(p)['parameter_type'] == 'primitive']
-        if key not in primitive_parameters:
+        key, subkey = key.split('.', 1) if '.' in key else (key, None)
+        if key in primitive_parameters:
+            value = context.typify_parameter(key, item)
+            rc_config[key] = value
+        elif key in map_parameters:
+            argmap = rc_config.setdefault(key, {})
+            argmap[subkey] = item
+        else:
             from ..exceptions import CondaValueError
             raise CondaValueError("Key '%s' is not a known primitive parameter." % key)
-        value = context.typify_parameter(key, item)
-        rc_config[key] = value
 
     # Remove
     for key, item in args.remove:
+        key, subkey = key.split('.', 1) if '.' in key else (key, None)
         if key not in rc_config:
             if key != 'channels':
                 from ..exceptions import CondaKeyError
@@ -408,6 +421,7 @@ def execute_config(args, parser):
 
     # Remove Key
     for key, in args.remove_key:
+        key, subkey = key.split('.', 1) if '.' in key else (key, None)
         if key not in rc_config:
             from ..exceptions import CondaKeyError
             raise CondaKeyError(key, "key %r is not in the config file" %


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -660,12 +660,31 @@ def test_config_set():
         assert stdout == ''
         assert stderr == ''
 
+        with open(rc) as fh:
+            content = yaml_load(fh.read())
+            assert content['always_yes'] is True
+
         stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
                                                   '--set', 'always_yes', 'no')
 
         assert stdout == ''
         assert stderr == ''
 
+        with open(rc) as fh:
+            content = yaml_load(fh.read())
+            assert content['always_yes'] is False
+
+        stdout, stderr, return_code = run_command(Commands.CONFIG, '--file', rc,
+                                                  '--set', 'proxy_servers.http', '1.2.3.4:5678')
+
+        assert stdout == ''
+        assert stderr == ''
+
+        with open(rc) as fh:
+            content = yaml_load(fh.read())
+            assert content['always_yes'] is False
+            assert content['proxy_servers'] == {'http': '1.2.3.4:5678'}
+
 
 def test_set_rc_string():
     # Test setting string keys in .condarc