diff --git a/dvc/command/imp.py b/dvc/command/imp.py index 524f28849..d55b98858 100644 --- a/dvc/command/imp.py +++ b/dvc/command/imp.py @@ -15,6 +15,7 @@ class CmdImport(CmdBase): self.args.url, self.args.path, out=self.args.out, + fname=self.args.file, rev=self.args.rev, ) except DvcException: @@ -59,4 +60,9 @@ def add_parser(subparsers, parent_parser): help="Git revision (e.g. SHA, branch, tag)", metavar="", ) + import_parser.add_argument( + "--file", + help="Specify name of the DVC-file this command will generate.", + metavar="", + ) import_parser.set_defaults(func=CmdImport) diff --git a/dvc/repo/imp.py b/dvc/repo/imp.py index 8b69841df..0b67ab6bb 100644 --- a/dvc/repo/imp.py +++ b/dvc/repo/imp.py @@ -1,6 +1,6 @@ -def imp(self, url, path, out=None, rev=None): +def imp(self, url, path, out=None, fname=None, rev=None): erepo = {"url": url} if rev is not None: erepo["rev"] = rev - return self.imp_url(path, out=out, erepo=erepo, frozen=True) + return self.imp_url(path, out=out, fname=fname, erepo=erepo, frozen=True) diff --git a/tests/unit/command/test_imp.py b/tests/unit/command/test_imp.py index f149ee5dc..bf87e9824 100644 --- a/tests/unit/command/test_imp.py +++ b/tests/unit/command/test_imp.py @@ -4,7 +4,17 @@ from dvc.command.imp import CmdImport def test_import(mocker): cli_args = parse_args( - ["import", "repo_url", "src", "--out", "out", "--rev", "version"] + [ + "import", + "repo_url", + "src", + "--out", + "out", + "--file", + "file", + "--rev", + "version", + ] ) assert cli_args.func == CmdImport @@ -13,4 +23,6 @@ def test_import(mocker): assert cmd.run() == 0 - m.assert_called_once_with("repo_url", path="src", out="out", rev="version") + m.assert_called_once_with( + "repo_url", path="src", out="out", fname="file", rev="version" + )