Repository: iterative/dvc

Issue:
Add option for `dvc remote add` to set default remote
Currently when you setup first remote for your repo, you need to manually set it as a default one in a config:
```
dvc remote add myremote s3://mybucket/
dvc config core.remote myremote
```
Lets just do it automatically by providing -d|--default option for `dvc remote add`.

Discussion:

Patch:
diff --git a/dvc/cli.py b/dvc/cli.py
index 7d6f553b9..d7696ab76 100644
--- a/dvc/cli.py
+++ b/dvc/cli.py
@@ -332,6 +332,11 @@ def parse_args(argv=None):
                         action='store_true',
                         default=False,
                         help='Use local config')
+    remote_add_parser.add_argument('-d',
+                        '--default',
+                        action='store_true',
+                        default=False,
+                        help='Set as default remote')
     remote_add_parser.set_defaults(func=CmdRemoteAdd)
 
 
diff --git a/dvc/command/remote.py b/dvc/command/remote.py
index d0335d830..cca6ddb90 100644
--- a/dvc/command/remote.py
+++ b/dvc/command/remote.py
@@ -8,8 +8,15 @@ from dvc.logger import Logger
 class CmdRemoteAdd(CmdConfig):
     def run(self):
         section = Config.SECTION_REMOTE_FMT.format(self.args.name)
-        return self.set(section, Config.SECTION_REMOTE_URL, self.args.url)
+        ret = self.set(section, Config.SECTION_REMOTE_URL, self.args.url)
+        if ret != 0:
+            return ret
 
+        if self.args.default:
+            Logger.info('Setting \'{}\' as a default remote.'.format(self.args.name))
+            ret = self.set(Config.SECTION_CORE, Config.SECTION_CORE_REMOTE, self.args.name)
+
+        return ret
 
 class CmdRemoteRemove(CmdConfig):
     def run(self):


Test patch:
diff --git a/tests/test_remote.py b/tests/test_remote.py
index 8ad6b35b6..cdc74e5c7 100644
--- a/tests/test_remote.py
+++ b/tests/test_remote.py
@@ -11,7 +11,7 @@ class TestRemote(TestDvc):
         self.assertNotEqual(main(['remote', 'remove', remotes[0]]), 0)
 
         for r in remotes:
-            self.assertEqual(main(['remote', 'add', r, 's3://bucket/name']), 0)
+            self.assertEqual(main(['remote', 'add', '--default', r, 's3://bucket/name']), 0)
 
         self.assertEqual(main(['remote', 'list']), 0)