From 2351fc12d28cf341e7c55b87b43dec4d2c05bdae Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Mon, 12 Feb 2018 13:14:07 +0200 Subject: [PATCH] dvc: move status/pull/push under cache subcmd Fixes #449 Signed-off-by: Ruslan Kuprieiev --- dvc/cli.py | 26 +++++++++++++++++--------- tests/test_cli.py | 6 +++--- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/dvc/cli.py b/dvc/cli.py index c17b65203..a1be92d47 100644 --- a/dvc/cli.py +++ b/dvc/cli.py @@ -123,34 +123,42 @@ def parse_args(argv=None): help='Command or command file to execute') run_parser.set_defaults(func=CmdRun) - # Parent parser used in sync/pull/push - parent_sync_parser = argparse.ArgumentParser( + # Parent parser used in pull/push/status + parent_cache_parser = argparse.ArgumentParser( add_help=False, parents=[parent_parser]) - parent_sync_parser.add_argument('-j', + parent_cache_parser.add_argument('-j', '--jobs', type=int, default=cpu_count(), help='Number of jobs to run simultaneously.') + # Cache + cache_parser = subparsers.add_parser( + 'cache', + parents=[parent_parser], + help='Cache operations') + cache_subparsers = cache_parser.add_subparsers( + dest='cmd', + help='Use `dvc cache CMD` --help for command-specific help') # Pull - pull_parser = subparsers.add_parser( + pull_parser = cache_subparsers.add_parser( 'pull', - parents=[parent_sync_parser], + parents=[parent_cache_parser], help='Pull data files from the cloud') pull_parser.set_defaults(func=CmdDataPull) # Push - push_parser = subparsers.add_parser( + push_parser = cache_subparsers.add_parser( 'push', - parents=[parent_sync_parser], + parents=[parent_cache_parser], help='Push data files to the cloud') push_parser.set_defaults(func=CmdDataPush) # Status - status_parser = subparsers.add_parser( + status_parser = cache_subparsers.add_parser( 'status', - parents=[parent_sync_parser], + parents=[parent_cache_parser], help='Show mismatches between local cache and cloud cache') status_parser.set_defaults(func=CmdDataStatus) diff --git a/tests/test_cli.py b/tests/test_cli.py index 8f9a8cf52..d4500d110 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -62,19 +62,19 @@ class TestRun(TestDvc): class TestPull(TestDvc): def test(self): - args = parse_args(['pull']) + args = parse_args(['cache', 'pull']) self.assertIsInstance(args.func(args), CmdDataPull) class TestPush(TestDvc): def test(self): - args = parse_args(['push']) + args = parse_args(['cache', 'push']) self.assertIsInstance(args.func(args), CmdDataPush) class TestStatus(TestDvc): def test(self): - args = parse_args(['status']) + args = parse_args(['cache', 'status']) self.assertIsInstance(args.func(args), CmdDataStatus)