run: automatic dvcfile name generation for directories
When -f not specified and -o is a directory and --cwd is specified, `dvc run` generates wrong fname for the resulting dvcfile.

Kudos @Nicolabo for discovering!
diff --git a/dvc/command/run.py b/dvc/command/run.py
index b2fec20f6..de6ffc82e 100644
--- a/dvc/command/run.py
+++ b/dvc/command/run.py
@@ -43,6 +43,6 @@ class CmdRun(CmdBase):
     def _stage_file_basename(fname):
         result = os.path.basename(fname)
         if len(result) == 0:
-            result = os.path.dirname(fname)
+            result = os.path.basename(os.path.dirname(fname))
         result += Stage.STAGE_FILE_SUFFIX
         return result
['dvc/command/run.py']