diff --git a/dvc/cli.py b/dvc/cli.py index 394aa8f8b..9028931ff 100644 --- a/dvc/cli.py +++ b/dvc/cli.py @@ -10,7 +10,8 @@ from dvc.command.init import CmdInit from dvc.command.remove import CmdRemove from dvc.command.run import CmdRun from dvc.command.repro import CmdRepro -from dvc.command.data_sync import CmdDataPush, CmdDataPull, CmdDataStatus, CmdDataFetch +from dvc.command.data_sync import CmdDataPush, CmdDataPull, CmdDataFetch +from dvc.command.status import CmdDataStatus from dvc.command.gc import CmdGC from dvc.command.add import CmdAdd from dvc.command.config import CmdConfig diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index a71417a7f..f174c3b63 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -48,31 +48,3 @@ class CmdDataFetch(CmdDataBase): self.project.logger.error('Failed to fetch data from the cloud', exc) return 1 return 0 - - -class CmdDataStatus(CmdDataBase): - def _show(self, status): - for s in status: - target, ret = s - - if ret == cloud.STATUS_UNKNOWN or ret == cloud.STATUS_OK: - continue - - prefix_map = { - cloud.STATUS_DELETED : 'deleted: ', - cloud.STATUS_MODIFIED : 'modified:', - cloud.STATUS_NEW : 'new file:', - } - - path = os.path.relpath(target, self.project.cache.cache_dir) - - self.project.logger.info('\t{}\t{}'.format(prefix_map[ret], path)) - - def do_run(self, target=None): - try: - status = self.project.status(target=target, jobs=self.args.jobs) - self._show(status) - except Exception as exc: - self.project.logger.error('Failed to obtain data status', exc) - return 1 - return 0 diff --git a/dvc/command/status.py b/dvc/command/status.py new file mode 100644 index 000000000..cb0ddb939 --- /dev/null +++ b/dvc/command/status.py @@ -0,0 +1,33 @@ +import os + +import dvc.cloud.base as cloud + +from dvc.command.data_sync import CmdDataBase + + +class CmdDataStatus(CmdDataBase): + def _show(self, status): + for s in status: + target, ret = s + + if ret == cloud.STATUS_UNKNOWN or ret == cloud.STATUS_OK: + continue + + prefix_map = { + cloud.STATUS_DELETED : 'deleted: ', + cloud.STATUS_MODIFIED : 'modified:', + cloud.STATUS_NEW : 'new file:', + } + + path = os.path.relpath(target, self.project.cache.cache_dir) + + self.project.logger.info('\t{}\t{}'.format(prefix_map[ret], path)) + + def do_run(self, target=None): + try: + status = self.project.status(target=target, jobs=self.args.jobs) + self._show(status) + except Exception as exc: + self.project.logger.error('Failed to obtain data status', exc) + return 1 + return 0 diff --git a/tests/test_cli.py b/tests/test_cli.py index 9c975b540..ad86a2dec 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,7 +3,8 @@ import os from dvc.cli import parse_args from dvc.command.init import CmdInit from dvc.command.run import CmdRun -from dvc.command.data_sync import CmdDataPull, CmdDataPush, CmdDataStatus +from dvc.command.data_sync import CmdDataPull, CmdDataPush +from dvc.command.status import CmdDataStatus from dvc.command.repro import CmdRepro from dvc.command.add import CmdAdd from dvc.command.remove import CmdRemove