run: hide and forbid --file for multistage files (#4086)

Fixes #4084
This commit is contained in:
Ruslan Kuprieiev
2020-06-23 03:46:59 +03:00
committed by GitHub
parent 5cb775308d
commit 4181c0ec4a
4 changed files with 19 additions and 3 deletions
+1 -3
View File
@@ -159,9 +159,7 @@ def add_parser(subparsers, parent_parser):
metavar="<path>",
)
run_parser.add_argument(
"--file",
help="Specify name of the DVC-file this command will generate.",
metavar="<filename>",
"--file", metavar="<filename>", help=argparse.SUPPRESS,
)
run_parser.add_argument(
"-w",
+6
View File
@@ -91,6 +91,12 @@ def run(self, fname=None, no_exec=False, single_stage=False, **kwargs):
"`-n|--name` is incompatible with `--single-stage`"
)
if stage_name and fname:
raise InvalidArgumentError(
"`--file` is currently incompatible with `-n|--name` "
"and requires `--single-stage`"
)
if not stage_name and not single_stage:
raise InvalidArgumentError("`-n|--name` is required")
View File
+12
View File
@@ -0,0 +1,12 @@
import pytest
from dvc.exceptions import InvalidArgumentError
def test_file(tmp_dir, dvc):
msg = (
"`--file` is currently incompatible with `-n|--name` "
"and requires `--single-stage`"
)
with pytest.raises(InvalidArgumentError, match=msg):
dvc.run(fname="path/dvc.yaml", name="my", cmd="mycmd")