diff --git a/gto/cli.py b/gto/cli.py index 779a4ec..c96e863 100644 --- a/gto/cli.py +++ b/gto/cli.py @@ -732,6 +732,8 @@ def show( # pylint: disable=too-many-locals arg = "stage" if show_stage else arg arg = "ref" if show_ref else arg if arg: + if not output[0]: + return if arg not in output[0][0]: raise WrongArgs(f"Cannot apply --{arg}") format_echo( diff --git a/tests/test_cli.py b/tests/test_cli.py index e17768b..a7cfdb4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -497,6 +497,11 @@ def test_show_ref_flag_not_applicable(repo_with_commit: str): ) +def test_show_line_flag_empty_result(): + with mock.patch("gto.api.show", return_value=([], "keys")): + _check_successful_cmd("show", ["-r", ".", "m5#missing", "--version"], "") + + def test_history_json_empty(repo_with_commit: str): _check_successful_cmd("history", ["-r", repo_with_commit, "--json"], "[]\n")