Repository: iterative/dvc

Issue:
Rename --outs-only
The param `--outs-only` for `dvc list` is not intuitive.


Discussion:
Hi @ahmed-shariff !

Maybe you have some suggestions?
`--dvc-only`?


Patch:
diff --git a/dvc/command/ls/__init__.py b/dvc/command/ls/__init__.py
--- a/dvc/command/ls/__init__.py
+++ b/dvc/command/ls/__init__.py
@@ -31,7 +31,7 @@ def run(self):
                 self.args.path,
                 rev=self.args.rev,
                 recursive=self.args.recursive,
-                outs_only=self.args.outs_only,
+                dvc_only=self.args.dvc_only,
             )
             if entries:
                 entries = _prettify(entries, sys.stdout.isatty())
@@ -62,7 +62,7 @@ def add_parser(subparsers, parent_parser):
         help="Recursively list files.",
     )
     list_parser.add_argument(
-        "--outs-only", action="store_true", help="Show only DVC outputs."
+        "--dvc-only", action="store_true", help="Show only DVC outputs."
     )
     list_parser.add_argument(
         "--rev",
diff --git a/dvc/command/remove.py b/dvc/command/remove.py
--- a/dvc/command/remove.py
+++ b/dvc/command/remove.py
@@ -9,7 +9,7 @@
 
 
 class CmdRemove(CmdBase):
-    def _is_outs_only(self, target):
+    def _is_dvc_only(self, target):
         if not self.args.purge:
             return True
 
@@ -31,8 +31,8 @@ def _is_outs_only(self, target):
     def run(self):
         for target in self.args.targets:
             try:
-                outs_only = self._is_outs_only(target)
-                self.repo.remove(target, outs_only=outs_only)
+                dvc_only = self._is_dvc_only(target)
+                self.repo.remove(target, dvc_only=dvc_only)
             except DvcException:
                 logger.exception(f"failed to remove '{target}'")
                 return 1
diff --git a/dvc/exceptions.py b/dvc/exceptions.py
--- a/dvc/exceptions.py
+++ b/dvc/exceptions.py
@@ -294,19 +294,15 @@ class PathMissingError(DvcException):
         "The path '{}' does not exist in the target repository '{}'"
         " neither as a DVC output nor as a Git-tracked file."
     )
-    default_msg_output_only = (
+    default_msg_dvc_only = (
         "The path '{}' does not exist in the target repository '{}'"
         " as an DVC output."
     )
 
-    def __init__(self, path, repo, output_only=False):
-        msg = (
-            self.default_msg
-            if not output_only
-            else self.default_msg_output_only
-        )
+    def __init__(self, path, repo, dvc_only=False):
+        msg = self.default_msg if not dvc_only else self.default_msg_dvc_only
         super().__init__(msg.format(path, repo))
-        self.output_only = output_only
+        self.dvc_only = dvc_only
 
 
 class RemoteCacheRequiredError(DvcException):
diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py
--- a/dvc/repo/ls.py
+++ b/dvc/repo/ls.py
@@ -4,7 +4,7 @@
 
 @staticmethod
 def ls(
-    url, path=None, rev=None, recursive=None, outs_only=False,
+    url, path=None, rev=None, recursive=None, dvc_only=False,
 ):
     """Methods for getting files and outputs for the repo.
 
@@ -13,7 +13,7 @@ def ls(
         path (str, optional): relative path into the repo
         rev (str, optional): SHA commit, branch or tag name
         recursive (bool, optional): recursively walk the repo
-        outs_only (bool, optional): show only DVC-artifacts
+        dvc_only (bool, optional): show only DVC-artifacts
 
     Returns:
         list of `entry`
@@ -40,13 +40,13 @@ def ls(
             ret = _ls(repo, path_info, recursive, True)
 
         nondvc = {}
-        if not outs_only:
+        if not dvc_only:
             nondvc = _ls(repo, path_info, recursive, False)
 
         ret.update(nondvc)
 
         if path and not ret:
-            raise PathMissingError(path, repo, output_only=outs_only)
+            raise PathMissingError(path, repo, dvc_only=dvc_only)
 
         ret_list = []
         for path, info in ret.items():
diff --git a/dvc/repo/remove.py b/dvc/repo/remove.py
--- a/dvc/repo/remove.py
+++ b/dvc/repo/remove.py
@@ -7,7 +7,7 @@
 
 
 @locked
-def remove(self, target, outs_only=False):
+def remove(self, target, dvc_only=False):
     from ..dvcfile import Dvcfile
 
     path, name = parse_target(target)
@@ -16,7 +16,7 @@ def remove(self, target, outs_only=False):
     for stage in stages:
         stage.remove_outs(force=True)
 
-    if not outs_only:
+    if not dvc_only:
         dvcfile.remove()
 
     return stages


Test patch:
diff --git a/tests/func/test_gc.py b/tests/func/test_gc.py
--- a/tests/func/test_gc.py
+++ b/tests/func/test_gc.py
@@ -68,7 +68,7 @@ def test(self):
         self.dvc.scm.tag("v1.0")
 
         self.dvc.scm.checkout("test", create_new=True)
-        self.dvc.remove(stages[0].relpath, outs_only=True)
+        self.dvc.remove(stages[0].relpath, dvc_only=True)
         with open(fname, "w+") as fobj:
             fobj.write("test")
         stages = self.dvc.add(fname)
@@ -77,7 +77,7 @@ def test(self):
         self.dvc.scm.commit("test")
 
         self.dvc.scm.checkout("master")
-        self.dvc.remove(stages[0].relpath, outs_only=True)
+        self.dvc.remove(stages[0].relpath, dvc_only=True)
         with open(fname, "w+") as fobj:
             fobj.write("trash")
         stages = self.dvc.add(fname)
@@ -85,7 +85,7 @@ def test(self):
         self.dvc.scm.add([".gitignore", stages[0].relpath])
         self.dvc.scm.commit("trash")
 
-        self.dvc.remove(stages[0].relpath, outs_only=True)
+        self.dvc.remove(stages[0].relpath, dvc_only=True)
         with open(fname, "w+") as fobj:
             fobj.write("master")
         stages = self.dvc.add(fname)
diff --git a/tests/func/test_ls.py b/tests/func/test_ls.py
--- a/tests/func/test_ls.py
+++ b/tests/func/test_ls.py
@@ -123,11 +123,11 @@ def test_ls_repo_recursive(tmp_dir, dvc, scm):
     )
 
 
-def test_ls_repo_outs_only_recursive(tmp_dir, dvc, scm):
+def test_ls_repo_dvc_only_recursive(tmp_dir, dvc, scm):
     tmp_dir.scm_gen(FS_STRUCTURE, commit="init")
     tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc")
 
-    files = Repo.ls(os.fspath(tmp_dir), recursive=True, outs_only=True)
+    files = Repo.ls(os.fspath(tmp_dir), recursive=True, dvc_only=True)
     match_files(
         files,
         (
@@ -156,13 +156,13 @@ def test_ls_repo_with_path_dir(tmp_dir, dvc, scm):
     )
 
 
-def test_ls_repo_with_path_dir_outs_only_empty(tmp_dir, dvc, scm):
+def test_ls_repo_with_path_dir_dvc_only_empty(tmp_dir, dvc, scm):
     tmp_dir.scm_gen(FS_STRUCTURE, commit="init")
     tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc")
     tmp_dir.scm_gen({"folder/.keep": "content"}, commit="add .keep")
 
     with pytest.raises(PathMissingError):
-        Repo.ls(os.fspath(tmp_dir), path="folder", outs_only=True)
+        Repo.ls(os.fspath(tmp_dir), path="folder", dvc_only=True)
 
 
 def test_ls_repo_with_path_subdir(tmp_dir, dvc, scm):
@@ -182,21 +182,21 @@ def test_ls_repo_with_path_subdir(tmp_dir, dvc, scm):
     )
 
 
-def test_ls_repo_with_path_subdir_outs_only(tmp_dir, dvc, scm):
+def test_ls_repo_with_path_subdir_dvc_only(tmp_dir, dvc, scm):
     tmp_dir.scm_gen(FS_STRUCTURE, commit="init")
     tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc")
 
     path = os.path.join("data", "subcontent")
-    files = Repo.ls(os.fspath(tmp_dir), path, outs_only=True)
+    files = Repo.ls(os.fspath(tmp_dir), path, dvc_only=True)
     match_files(files, ((("data.xml",), True), (("statistics",), False),))
 
 
-def test_ls_repo_with_path_subdir_outs_only_recursive(tmp_dir, dvc, scm):
+def test_ls_repo_with_path_subdir_dvc_only_recursive(tmp_dir, dvc, scm):
     tmp_dir.scm_gen(FS_STRUCTURE, commit="init")
     tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc")
 
     path = os.path.join("data", "subcontent")
-    files = Repo.ls(os.fspath(tmp_dir), path, outs_only=True, recursive=True)
+    files = Repo.ls(os.fspath(tmp_dir), path, dvc_only=True, recursive=True)
     match_files(
         files, ((("data.xml",), True), (("statistics", "data.csv"), True),)
     )
@@ -226,10 +226,10 @@ def test_ls_repo_with_missed_path(tmp_dir, dvc, scm):
 
     with pytest.raises(PathMissingError) as exc_info:
         Repo.ls(os.fspath(tmp_dir), path="missed_path")
-    assert not exc_info.value.output_only
+    assert not exc_info.value.dvc_only
 
 
-def test_ls_repo_with_missed_path_outs_only(tmp_dir, dvc, scm):
+def test_ls_repo_with_missed_path_dvc_only(tmp_dir, dvc, scm):
     tmp_dir.scm_gen(FS_STRUCTURE, commit="init")
     tmp_dir.dvc_gen(DVC_STRUCTURE, commit="dvc")
 
@@ -238,9 +238,9 @@ def test_ls_repo_with_missed_path_outs_only(tmp_dir, dvc, scm):
             os.fspath(tmp_dir),
             path="missed_path",
             recursive=True,
-            outs_only=True,
+            dvc_only=True,
         )
-    assert exc_info.value.output_only
+    assert exc_info.value.dvc_only
 
 
 def test_ls_repo_with_removed_dvc_dir(tmp_dir, dvc, scm):
@@ -440,5 +440,5 @@ def test_ls_shows_pipeline_tracked_outs(tmp_dir, dvc, scm, run_copy):
     dvc.scm.add([PIPELINE_FILE, PIPELINE_LOCK])
     dvc.scm.commit("add pipeline stage")
 
-    files = Repo.ls(os.curdir, outs_only=True)
+    files = Repo.ls(os.curdir, dvc_only=True)
     match_files(files, ((("bar",), True),))
diff --git a/tests/func/test_remove.py b/tests/func/test_remove.py
--- a/tests/func/test_remove.py
+++ b/tests/func/test_remove.py
@@ -17,7 +17,7 @@ def test(self):
         self.assertEqual(len(stages), 1)
         stage = stages[0]
         self.assertTrue(stage is not None)
-        (stage_removed,) = self.dvc.remove(stage.path, outs_only=True)
+        (stage_removed,) = self.dvc.remove(stage.path, dvc_only=True)
 
         self.assertIsInstance(stage_removed, Stage)
         self.assertEqual(stage.path, stage_removed.path)
diff --git a/tests/func/test_repro.py b/tests/func/test_repro.py
--- a/tests/func/test_repro.py
+++ b/tests/func/test_repro.py
@@ -971,7 +971,7 @@ def test(self, mock_prompt):
         self.dvc.gc(workspace=True)
         self.assertEqual(self.dvc.status(), {})
 
-        self.dvc.remove(cmd_stage.path, outs_only=True)
+        self.dvc.remove(cmd_stage.path, dvc_only=True)
         self.assertNotEqual(self.dvc.status([cmd_stage.addressing]), {})
 
         self.dvc.checkout([cmd_stage.path], force=True)
@@ -1223,7 +1223,7 @@ def test(self):
             self.assertTrue(os.path.exists(run_output))
 
             # Pull
-            self.dvc.remove(import_stage.path, outs_only=True)
+            self.dvc.remove(import_stage.path, dvc_only=True)
             self.assertFalse(os.path.exists(import_output))
 
             shutil.move(self.local_cache, cache_id)
diff --git a/tests/unit/command/ls/test_ls.py b/tests/unit/command/ls/test_ls.py
--- a/tests/unit/command/ls/test_ls.py
+++ b/tests/unit/command/ls/test_ls.py
@@ -17,7 +17,7 @@ def test_list(mocker):
     url = "local_dir"
     m = _test_cli(mocker, url)
     m.assert_called_once_with(
-        url, None, recursive=False, rev=None, outs_only=False
+        url, None, recursive=False, rev=None, dvc_only=False
     )
 
 
@@ -25,7 +25,7 @@ def test_list_recursive(mocker):
     url = "local_dir"
     m = _test_cli(mocker, url, "-R")
     m.assert_called_once_with(
-        url, None, recursive=True, rev=None, outs_only=False
+        url, None, recursive=True, rev=None, dvc_only=False
     )
 
 
@@ -33,7 +33,7 @@ def test_list_git_ssh_rev(mocker):
     url = "git@github.com:repo"
     m = _test_cli(mocker, url, "--rev", "123")
     m.assert_called_once_with(
-        url, None, recursive=False, rev="123", outs_only=False
+        url, None, recursive=False, rev="123", dvc_only=False
     )
 
 
@@ -42,13 +42,13 @@ def test_list_targets(mocker):
     target = "subdir"
     m = _test_cli(mocker, url, target)
     m.assert_called_once_with(
-        url, target, recursive=False, rev=None, outs_only=False
+        url, target, recursive=False, rev=None, dvc_only=False
     )
 
 
 def test_list_outputs_only(mocker):
     url = "local_dir"
-    m = _test_cli(mocker, url, None, "--outs-only")
+    m = _test_cli(mocker, url, None, "--dvc-only")
     m.assert_called_once_with(
-        url, None, recursive=False, rev=None, outs_only=True
+        url, None, recursive=False, rev=None, dvc_only=True
     )