diff --git a/dvc/command/add.py b/dvc/command/add.py index d9c1da4b9..487dd654d 100644 --- a/dvc/command/add.py +++ b/dvc/command/add.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdAdd(CmdBase): @@ -26,12 +28,14 @@ class CmdAdd(CmdBase): def add_parser(subparsers, parent_parser): - ADD_HELP = ( - "Add files/directories to dvc.\n" - "documentation: https://man.dvc.org/add" - ) + ADD_HELP = "Take data files or directories under DVC control." + add_parser = subparsers.add_parser( - "add", parents=[parent_parser], description=ADD_HELP, help=ADD_HELP + "add", + parents=[parent_parser], + description=append_doc_link(ADD_HELP, "add"), + help=ADD_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) add_parser.add_argument( "-R", diff --git a/dvc/command/base.py b/dvc/command/base.py index 53177ea94..9c9e9eb3c 100644 --- a/dvc/command/base.py +++ b/dvc/command/base.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals +import colorama + import dvc.logger as logger @@ -18,6 +20,19 @@ def fix_subparsers(subparsers): subparsers.dest = "cmd" +def append_doc_link(help_message, path): + if not path: + return help_message + doc_base = "https://man.dvc.org/" + return "{message}\ndocumentation: {blue}{base}{path}{nc}".format( + message=help_message, + base=doc_base, + path=path, + blue=colorama.Fore.CYAN, + nc=colorama.Fore.RESET, + ) + + class CmdBase(object): def __init__(self, args): from dvc.repo import Repo diff --git a/dvc/command/cache.py b/dvc/command/cache.py index 237b21b38..80b189cae 100644 --- a/dvc/command/cache.py +++ b/dvc/command/cache.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import argparse -from dvc.command.base import fix_subparsers +from dvc.command.base import fix_subparsers, append_doc_link from dvc.command.remote import CmdRemoteAdd from dvc.command.config import CmdConfig @@ -20,14 +20,14 @@ class CmdCacheDir(CmdConfig): def add_parser(subparsers, parent_parser): from dvc.command.config import parent_config_parser - CACHE_HELP = ( - "Manage cache settings.\ndocumentation: https://man.dvc.org/cache" - ) + CACHE_HELP = "Manage cache settings." + cache_parser = subparsers.add_parser( "cache", parents=[parent_parser], - description=CACHE_HELP, + description=append_doc_link(CACHE_HELP, "cache"), help=CACHE_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) cache_subparsers = cache_parser.add_subparsers( @@ -40,11 +40,13 @@ def add_parser(subparsers, parent_parser): add_help=False, parents=[parent_config_parser] ) CACHE_DIR_HELP = "Configure cache directory location." + cache_dir_parser = cache_subparsers.add_parser( "dir", parents=[parent_cache_config_parser], - description=CACHE_DIR_HELP, + description=append_doc_link(CACHE_HELP, "cache-dir"), help=CACHE_DIR_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) cache_dir_parser.add_argument( "-u", diff --git a/dvc/command/checkout.py b/dvc/command/checkout.py index 0f0e0d5ef..5a9aa05eb 100644 --- a/dvc/command/checkout.py +++ b/dvc/command/checkout.py @@ -1,6 +1,8 @@ from __future__ import unicode_literals -from dvc.command.base import CmdBase +import argparse + +from dvc.command.base import CmdBase, append_doc_link class CmdCheckout(CmdBase): @@ -19,15 +21,14 @@ class CmdCheckout(CmdBase): def add_parser(subparsers, parent_parser): - CHECKOUT_HELP = ( - "Checkout data files from cache.\n" - "documentation: https://man.dvc.org/checkout" - ) + CHECKOUT_HELP = "Checkout data files from cache." + checkout_parser = subparsers.add_parser( "checkout", parents=[parent_parser], - description=CHECKOUT_HELP, + description=append_doc_link(CHECKOUT_HELP, "checkout"), help=CHECKOUT_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) checkout_parser.add_argument( "-d", diff --git a/dvc/command/commit.py b/dvc/command/commit.py index a840f7c3f..611f72bf7 100644 --- a/dvc/command/commit.py +++ b/dvc/command/commit.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdCommit(CmdBase): @@ -29,15 +31,14 @@ class CmdCommit(CmdBase): def add_parser(subparsers, parent_parser): - COMMIT_HELP = ( - "Record changes to the repository.\n" - "documentation: https://man.dvc.org/commit" - ) + COMMIT_HELP = "Save changed data to cache and update DVC files." + commit_parser = subparsers.add_parser( "commit", parents=[parent_parser], - description=COMMIT_HELP, + description=append_doc_link(COMMIT_HELP, "commit"), help=COMMIT_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) commit_parser.add_argument( "-f", diff --git a/dvc/command/config.py b/dvc/command/config.py index 97db45d6e..c4c049982 100644 --- a/dvc/command/config.py +++ b/dvc/command/config.py @@ -4,7 +4,7 @@ import os import argparse import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link from dvc.config import Config from dvc.exceptions import DvcException @@ -98,15 +98,14 @@ parent_config_parser.add_argument( def add_parser(subparsers, parent_parser): - CONFIG_HELP = ( - "Get or set config options.\n" - "documentation: https://man.dvc.org/config" - ) + CONFIG_HELP = "Get or set config options." + config_parser = subparsers.add_parser( "config", parents=[parent_config_parser, parent_parser], - description=CONFIG_HELP, + description=append_doc_link(CONFIG_HELP, "config"), help=CONFIG_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) config_parser.add_argument( "-u", diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index 09d204fce..6937484ff 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import argparse import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdDataBase(CmdBase): @@ -120,15 +120,14 @@ def add_parser(subparsers, _parent_parser): from dvc.command.status import CmdDataStatus # Pull - PULL_HELP = ( - "Pull data files from the cloud.\n" - "documentation: https://man.dvc.org/pull" - ) + PULL_HELP = "Pull data files from a DVC remote storage." + pull_parser = subparsers.add_parser( "pull", parents=[shared_parent_parser()], - description=PULL_HELP, + description=append_doc_link(PULL_HELP, "pull"), help=PULL_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) pull_parser.add_argument( "-r", "--remote", help="Remote repository to pull from." @@ -171,15 +170,14 @@ def add_parser(subparsers, _parent_parser): pull_parser.set_defaults(func=CmdDataPull) # Push - PUSH_HELP = ( - "Push data files to the cloud.\n" - "documentation: https://man.dvc.org/push" - ) + PUSH_HELP = "Push data files to a DVC remote storage." + push_parser = subparsers.add_parser( "push", parents=[shared_parent_parser()], - description=PUSH_HELP, + description=append_doc_link(PUSH_HELP, "push"), help=PUSH_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) push_parser.add_argument( "-r", "--remote", help="Remote repository to push to." @@ -215,15 +213,14 @@ def add_parser(subparsers, _parent_parser): push_parser.set_defaults(func=CmdDataPush) # Fetch - FETCH_HELP = ( - "Fetch data files from the cloud.\n" - "documentation: https://man.dvc.org/fetch" - ) + FETCH_HELP = "Fetch data files from a DVC remote storage." + fetch_parser = subparsers.add_parser( "fetch", parents=[shared_parent_parser()], - description=FETCH_HELP, + description=append_doc_link(FETCH_HELP, "fetch"), help=FETCH_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) fetch_parser.add_argument( "-r", "--remote", help="Remote repository to fetch from." @@ -260,14 +257,16 @@ def add_parser(subparsers, _parent_parser): # Status STATUS_HELP = ( - "Show the repo status.\ndocumentation: https://man.dvc.org/status" + "Show changed stages, compare local cache and a remote storage." ) + status_parser = subparsers.add_parser( "status", parents=[shared_parent_parser()], - description=STATUS_HELP, + description=append_doc_link(STATUS_HELP, "status"), help=STATUS_HELP, conflict_handler="resolve", + formatter_class=argparse.RawDescriptionHelpFormatter, ) status_parser.add_argument( "-q", diff --git a/dvc/command/destroy.py b/dvc/command/destroy.py index aab1d9bfc..837dba18e 100644 --- a/dvc/command/destroy.py +++ b/dvc/command/destroy.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import argparse + import dvc.prompt as prompt import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link from dvc.exceptions import DvcException @@ -30,16 +32,14 @@ class CmdDestroy(CmdBase): def add_parser(subparsers, parent_parser): - DESTROY_HELP = ( - "Destroy dvc. Will remove all repo's information, " - "data files and cache.\n" - "documentation: https://man.dvc.org/destroy" - ) + DESTROY_HELP = "Remove DVC files, local DVC config and data cache." + destroy_parser = subparsers.add_parser( "destroy", parents=[parent_parser], - description=DESTROY_HELP, + description=append_doc_link(DESTROY_HELP, "destroy"), help=DESTROY_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) destroy_parser.add_argument( "-f", diff --git a/dvc/command/gc.py b/dvc/command/gc.py index 1489caebe..582e06290 100644 --- a/dvc/command/gc.py +++ b/dvc/command/gc.py @@ -1,10 +1,11 @@ from __future__ import unicode_literals +import argparse import os import dvc.prompt as prompt import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdGC(CmdBase): @@ -46,14 +47,17 @@ class CmdGC(CmdBase): def add_parser(subparsers, parent_parser): - GC_HELP = ( - "Collect garbage from your DVC cache. \n" - "Deletes all files in the cache which are not in use by the \n" - "specified git references (defaults to just HEAD).\n" - "documentation: https://man.dvc.org/gc" + GC_HELP = "Collect unused data from DVC cache or a remote storage." + GC_DESCRIPTION = ( + "Deletes all files in the cache or a remote which are not in\n" + "use by the specified git references (defaults to just HEAD)." ) gc_parser = subparsers.add_parser( - "gc", parents=[parent_parser], description=GC_HELP, help=GC_HELP + "gc", + parents=[parent_parser], + description=append_doc_link(GC_DESCRIPTION, "gc"), + help=GC_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) gc_parser.add_argument( "-a", @@ -77,7 +81,7 @@ def add_parser(subparsers, parent_parser): help="Collect garbage in remote repository.", ) gc_parser.add_argument( - "-r", "--remote", help="Remote repository to collect garbage in." + "-r", "--remote", help="Remote storage to collect garbage in." ) gc_parser.add_argument( "-f", diff --git a/dvc/command/imp.py b/dvc/command/imp.py index ae0c2f457..6e925ab80 100644 --- a/dvc/command/imp.py +++ b/dvc/command/imp.py @@ -1,11 +1,12 @@ from __future__ import unicode_literals +import argparse import os import dvc.logger as logger from dvc.utils.compat import urlparse from dvc.exceptions import DvcException -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdImport(CmdBase): @@ -28,27 +29,26 @@ class CmdImport(CmdBase): def add_parser(subparsers, parent_parser): - IMPORT_HELP = ( - "Import files from URL.\ndocumentation: https://man.dvc.org/import" - ) + IMPORT_HELP = "Download or copy files from URL and take under DVC control." + import_parser = subparsers.add_parser( "import", parents=[parent_parser], - description=IMPORT_HELP, + description=append_doc_link(IMPORT_HELP, "import"), help=IMPORT_HELP, + formatter_class=argparse.RawTextHelpFormatter, ) import_parser.add_argument( "url", - help="URL. Supported urls: " - "'/path/to/file', " - "'C:\\\\path\\to\\file', " - "'https://example.com/path/to/file', " - "'s3://bucket/path/to/file', " - "'gs://bucket/path/to/file', " - "'hdfs://example.com/path/to/file', " - "'ssh://example.com:/path/to/file', " - "'remote://myremote/path/to/file'(see " - "`dvc remote` commands). ", + help="Supported urls:\n" + "/path/to/file\n" + "C:\\\\path\\to\\file\n" + "https://example.com/path/to/file\n" + "s3://bucket/path/to/file\n" + "gs://bucket/path/to/file\n" + "hdfs://example.com/path/to/file\n" + "ssh://example.com:/path/to/file\n" + "remote://myremote/path/to/file (see `dvc remote`)", ) import_parser.add_argument( "--resume", @@ -56,5 +56,7 @@ def add_parser(subparsers, parent_parser): default=False, help="Resume previously started download.", ) - import_parser.add_argument("out", nargs="?", help="Output.") + import_parser.add_argument( + "out", nargs="?", help="Destination path to put files to." + ) import_parser.set_defaults(func=CmdImport) diff --git a/dvc/command/init.py b/dvc/command/init.py index 134327317..3cf1a10ac 100644 --- a/dvc/command/init.py +++ b/dvc/command/init.py @@ -1,6 +1,9 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger +from dvc.command.base import append_doc_link class CmdInit(object): @@ -24,13 +27,18 @@ class CmdInit(object): def add_parser(subparsers, parent_parser): """Setup parser for `dvc init`.""" - INIT_HELP = ( - "Initialize dvc over a directory " - "(should already be a git dir).\n" - "documentation: https://man.dvc.org/init " + INIT_HELP = "Initialize DVC in the current directory." + INIT_DESCRIPTION = ( + "Initialize DVC in the current directory. Expects directory\n" + "to be a Git repository unless --no-scm option is specified." ) + init_parser = subparsers.add_parser( - "init", parents=[parent_parser], description=INIT_HELP, help=INIT_HELP + "init", + parents=[parent_parser], + description=append_doc_link(INIT_DESCRIPTION, "init"), + help=INIT_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) init_parser.add_argument( "--no-scm", @@ -44,6 +52,9 @@ def add_parser(subparsers, parent_parser): "--force", action="store_true", default=False, - help="Overwrite '.dvc' if it exists. Will remove all local cache.", + help=( + "Overwrite existing '.dvc' directory. " + "This operation removes local cache." + ), ) init_parser.set_defaults(func=CmdInit) diff --git a/dvc/command/install.py b/dvc/command/install.py index 1d7bdee09..775bfc414 100644 --- a/dvc/command/install.py +++ b/dvc/command/install.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdInstall(CmdBase): @@ -15,14 +17,12 @@ class CmdInstall(CmdBase): def add_parser(subparsers, parent_parser): - INSTALL_HELP = ( - "Install dvc hooks into the repository.\n" - "documentation: https://man.dvc.org/install" - ) + INSTALL_HELP = "Install DVC git hooks into the repository." install_parser = subparsers.add_parser( "install", parents=[parent_parser], - description=INSTALL_HELP, + description=append_doc_link(INSTALL_HELP, "install"), help=INSTALL_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) install_parser.set_defaults(func=CmdInstall) diff --git a/dvc/command/lock.py b/dvc/command/lock.py index afe614001..204bf0108 100644 --- a/dvc/command/lock.py +++ b/dvc/command/lock.py @@ -1,12 +1,14 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdLockBase(CmdBase): - def run(self, unlock=False): + def _run(self, unlock): for target in self.args.targets: try: self.repo.lock_stage(target, unlock=unlock) @@ -23,28 +25,33 @@ class CmdLockBase(CmdBase): class CmdLock(CmdLockBase): def run(self): - return super(CmdLock, self).run(False) + return self._run(False) class CmdUnlock(CmdLockBase): def run(self): - return super(CmdUnlock, self).run(True) + return self._run(True) def add_parser(subparsers, parent_parser): - LOCK_HELP = "Lock DVC file.\ndocumentation: https://man.dvc.org/lock" + LOCK_HELP = "Lock DVC file." lock_parser = subparsers.add_parser( - "lock", parents=[parent_parser], description=LOCK_HELP, help=LOCK_HELP + "lock", + parents=[parent_parser], + description=append_doc_link(LOCK_HELP, "lock"), + help=LOCK_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) lock_parser.add_argument("targets", nargs="+", help="DVC files.") lock_parser.set_defaults(func=CmdLock) - UNLOCK_HELP = "Unlock DVC file.\ndocumentation: https://man.dvc.org/unlock" + UNLOCK_HELP = "Unlock DVC file." unlock_parser = subparsers.add_parser( "unlock", parents=[parent_parser], - description=UNLOCK_HELP, + description=append_doc_link(UNLOCK_HELP, "unlock"), help=UNLOCK_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) unlock_parser.add_argument("targets", nargs="+", help="DVC files.") unlock_parser.set_defaults(func=CmdUnlock) diff --git a/dvc/command/metrics.py b/dvc/command/metrics.py index 6da22b7c8..8815c049a 100644 --- a/dvc/command/metrics.py +++ b/dvc/command/metrics.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase, fix_subparsers +from dvc.command.base import CmdBase, fix_subparsers, append_doc_link def show_metrics(metrics, all_branches=False, all_tags=False): @@ -76,15 +78,14 @@ class CmdMetricsRemove(CmdBase): def add_parser(subparsers, parent_parser): - METRICS_HELP = ( - "A set of commands to add, manage, collect and display project " - "metrics.\ndocumentation: https://man.dvc.org/metrics" - ) + METRICS_HELP = "Commands to add, manage, collect and display metrics." + metrics_parser = subparsers.add_parser( "metrics", parents=[parent_parser], - description=METRICS_HELP, + description=append_doc_link(METRICS_HELP, "metrics"), help=METRICS_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) metrics_subparsers = metrics_parser.add_subparsers( @@ -94,15 +95,13 @@ def add_parser(subparsers, parent_parser): fix_subparsers(metrics_subparsers) - METRICS_SHOW_HELP = ( - "Output metric values.\n" - "documentation: https://man.dvc.org/metrics-show" - ) + METRICS_SHOW_HELP = "Output metric values." metrics_show_parser = metrics_subparsers.add_parser( "show", parents=[parent_parser], - description=METRICS_SHOW_HELP, + description=append_doc_link(METRICS_SHOW_HELP, "metrics-show"), help=METRICS_SHOW_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) metrics_show_parser.add_argument( "path", nargs="?", help="Path to a metric file or a directory." @@ -139,15 +138,13 @@ def add_parser(subparsers, parent_parser): ) metrics_show_parser.set_defaults(func=CmdMetricsShow) - METRICS_ADD_HELP = ( - "Tag file as a metric file.\n" - "documentation: https://man.dvc.org/metrics-add" - ) + METRICS_ADD_HELP = "Tag file as a metric file." metrics_add_parser = metrics_subparsers.add_parser( "add", parents=[parent_parser], - description=METRICS_ADD_HELP, + description=append_doc_link(METRICS_ADD_HELP, "metrics-add"), help=METRICS_ADD_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) metrics_add_parser.add_argument( "-t", "--type", help="Type of metrics (raw/json/tsv/htsv/csv/hcsv)." @@ -158,15 +155,13 @@ def add_parser(subparsers, parent_parser): metrics_add_parser.add_argument("path", help="Path to a metric file.") metrics_add_parser.set_defaults(func=CmdMetricsAdd) - METRICS_MODIFY_HELP = ( - "Modify metric file options.\n" - "documentation: https://man.dvc.org/metrics-modify " - ) + METRICS_MODIFY_HELP = "Modify metric file options." metrics_modify_parser = metrics_subparsers.add_parser( "modify", parents=[parent_parser], - description=METRICS_MODIFY_HELP, + description=append_doc_link(METRICS_MODIFY_HELP, "metrics-modify"), help=METRICS_MODIFY_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) metrics_modify_parser.add_argument( "-t", "--type", help="Type of metrics (raw/json/tsv/htsv/csv/hcsv)." @@ -177,16 +172,13 @@ def add_parser(subparsers, parent_parser): metrics_modify_parser.add_argument("path", help="Path to a metric file.") metrics_modify_parser.set_defaults(func=CmdMetricsModify) - METRICS_REMOVE_HELP = ( - "Remove files's metric tag.\n" - "documentation: https://man.dvc.org/metrics-remove" - ) - + METRICS_REMOVE_HELP = "Remove files's metric tag." metrics_remove_parser = metrics_subparsers.add_parser( "remove", parents=[parent_parser], - description=METRICS_REMOVE_HELP, + description=append_doc_link(METRICS_REMOVE_HELP, "metrics-remove"), help=METRICS_REMOVE_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) metrics_remove_parser.add_argument("path", help="Path to a metric file.") metrics_remove_parser.set_defaults(func=CmdMetricsRemove) diff --git a/dvc/command/move.py b/dvc/command/move.py index 93bec3943..283344e6a 100644 --- a/dvc/command/move.py +++ b/dvc/command/move.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdMove(CmdBase): @@ -19,18 +21,19 @@ class CmdMove(CmdBase): def add_parser(subparsers, parent_parser): - MOVE_HELP = ( + MOVE_HELP = "Rename or move a DVC controlled data file or a directory." + MOVE_DESCRIPTION = ( "Rename or move a DVC controlled data file or a directory.\n" - "documentation: https://man.dvc.org/move" + "It renames and modifies the corresponding DVC file to reflect the" + " changes." ) - description = ( - "Rename or move a data file or a directory that " - "is under DVC control. It renames and modifies " - "the corresponding DVC file to reflect the changes." - ) - help = MOVE_HELP + move_parser = subparsers.add_parser( - "move", parents=[parent_parser], description=description, help=help + "move", + parents=[parent_parser], + description=append_doc_link(MOVE_DESCRIPTION, "move"), + help=MOVE_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) move_parser.add_argument( "src", help="Source path to a data file or directory." diff --git a/dvc/command/pipeline.py b/dvc/command/pipeline.py index f6b33e9b2..d1f10341a 100644 --- a/dvc/command/pipeline.py +++ b/dvc/command/pipeline.py @@ -1,12 +1,14 @@ from __future__ import unicode_literals +import argparse + from dvc.utils.compat import str import os import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase, fix_subparsers +from dvc.command.base import CmdBase, fix_subparsers, append_doc_link class CmdPipelineShow(CmdBase): @@ -165,14 +167,13 @@ class CmdPipelineList(CmdBase): def add_parser(subparsers, parent_parser): - PIPELINE_HELP = ( - "Manage pipeline.\ndocumentation: https://man.dvc.org/pipeline" - ) + PIPELINE_HELP = "Manage pipelines." pipeline_parser = subparsers.add_parser( "pipeline", parents=[parent_parser], - description=PIPELINE_HELP, + description=append_doc_link(PIPELINE_HELP, "pipeline"), help=PIPELINE_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) pipeline_subparsers = pipeline_parser.add_subparsers( @@ -186,8 +187,9 @@ def add_parser(subparsers, parent_parser): pipeline_show_parser = pipeline_subparsers.add_parser( "show", parents=[parent_parser], - description=PIPELINE_SHOW_HELP, + description=append_doc_link(PIPELINE_SHOW_HELP, "pipeline-show"), help=PIPELINE_SHOW_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) pipeline_show_group = pipeline_show_parser.add_mutually_exclusive_group() pipeline_show_group.add_argument( @@ -228,7 +230,8 @@ def add_parser(subparsers, parent_parser): pipeline_list_parser = pipeline_subparsers.add_parser( "list", parents=[parent_parser], - description=PIPELINE_LIST_HELP, + description=append_doc_link(PIPELINE_LIST_HELP, "pipeline-list"), help=PIPELINE_LIST_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) pipeline_list_parser.set_defaults(func=CmdPipelineList) diff --git a/dvc/command/pkg.py b/dvc/command/pkg.py index e4496c7ca..4f70541ce 100644 --- a/dvc/command/pkg.py +++ b/dvc/command/pkg.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase, fix_subparsers +from dvc.command.base import CmdBase, fix_subparsers, append_doc_link from dvc.repo.pkg import PackageParams @@ -27,9 +29,14 @@ class CmdPkg(CmdBase): def add_parser(subparsers, parent_parser): from dvc.command.config import parent_config_parser - PKG_HELP = "Manage packages and modules" + PKG_HELP = "Manage DVC packages." pkg_parser = subparsers.add_parser( - "pkg", parents=[parent_parser], description=PKG_HELP, add_help=False + "pkg", + parents=[parent_parser], + description=append_doc_link(PKG_HELP, "pkg"), + help=PKG_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, + add_help=False, ) pkg_subparsers = pkg_parser.add_subparsers( @@ -42,8 +49,9 @@ def add_parser(subparsers, parent_parser): pkg_install_parser = pkg_subparsers.add_parser( "install", parents=[parent_config_parser, parent_parser], - description=PKG_INSTALL_HELP, + description=append_doc_link(PKG_INSTALL_HELP, "pkg-install"), help=PKG_INSTALL_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) pkg_install_parser.add_argument( "address", diff --git a/dvc/command/remote.py b/dvc/command/remote.py index 279423112..fb03c536f 100644 --- a/dvc/command/remote.py +++ b/dvc/command/remote.py @@ -1,10 +1,11 @@ from __future__ import unicode_literals +import argparse import os import re import dvc.logger as logger -from dvc.command.base import fix_subparsers +from dvc.command.base import fix_subparsers, append_doc_link from dvc.config import Config from dvc.command.config import CmdConfig @@ -119,15 +120,13 @@ class CmdRemoteList(CmdConfig): def add_parser(subparsers, parent_parser): from dvc.command.config import parent_config_parser - REMOTE_HELP = ( - "Manage set of tracked repositories.\n" - "documentation: https://man.dvc.org/remote" - ) + REMOTE_HELP = "Manage remote storage configuration." remote_parser = subparsers.add_parser( "remote", parents=[parent_parser], - description=REMOTE_HELP, + description=append_doc_link(REMOTE_HELP, "remote"), help=REMOTE_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) remote_subparsers = remote_parser.add_subparsers( @@ -137,14 +136,13 @@ def add_parser(subparsers, parent_parser): fix_subparsers(remote_subparsers) - REMOTE_ADD_HELP = ( - "Add remote.\ndocumentation: https://man.dvc.org/remote-add" - ) + REMOTE_ADD_HELP = "Add remote." remote_add_parser = remote_subparsers.add_parser( "add", parents=[parent_config_parser, parent_parser], - description=REMOTE_ADD_HELP, + description=append_doc_link(REMOTE_ADD_HELP, "remote-add"), help=REMOTE_ADD_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) remote_add_parser.add_argument("name", help="Name.") remote_add_parser.add_argument( @@ -164,8 +162,9 @@ def add_parser(subparsers, parent_parser): remote_default_parser = remote_subparsers.add_parser( "default", parents=[parent_config_parser, parent_parser], - description=REMOTE_DEFAULT_HELP, + description=append_doc_link(REMOTE_DEFAULT_HELP, "remote-default"), help=REMOTE_DEFAULT_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) remote_default_parser.add_argument( "name", nargs="?", help="Name of the remote." @@ -179,26 +178,24 @@ def add_parser(subparsers, parent_parser): ) remote_default_parser.set_defaults(func=CmdRemoteDefault) - REMOTE_REMOVE_HELP = ( - "Remove remote.\ndocumentation: https://man.dvc.org/remote-remove" - ) + REMOTE_REMOVE_HELP = "Remove remote." remote_remove_parser = remote_subparsers.add_parser( "remove", parents=[parent_config_parser, parent_parser], - description=REMOTE_REMOVE_HELP, + description=append_doc_link(REMOTE_REMOVE_HELP, "remote-remove"), help=REMOTE_REMOVE_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) remote_remove_parser.add_argument("name", help="Name") remote_remove_parser.set_defaults(func=CmdRemoteRemove) - REMOTE_MODIFY_HELP = ( - "Modify remote.\ndocumentation: https://man.dvc.org/remote-modify" - ) + REMOTE_MODIFY_HELP = "Modify remote." remote_modify_parser = remote_subparsers.add_parser( "modify", parents=[parent_config_parser, parent_parser], - description=REMOTE_MODIFY_HELP, + description=append_doc_link(REMOTE_MODIFY_HELP, "remote-modify"), help=REMOTE_MODIFY_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) remote_modify_parser.add_argument("name", help="Name.") remote_modify_parser.add_argument("option", help="Option.") @@ -212,13 +209,12 @@ def add_parser(subparsers, parent_parser): ) remote_modify_parser.set_defaults(func=CmdRemoteModify) - REMOTE_LIST_HELP = ( - "List remotes.\ndocumentation: https://man.dvc.org/remote-list" - ) + REMOTE_LIST_HELP = "List available remotes." remote_list_parser = remote_subparsers.add_parser( "list", parents=[parent_config_parser, parent_parser], - description=REMOTE_LIST_HELP, + description=append_doc_link(REMOTE_LIST_HELP, "remote-list"), help=REMOTE_LIST_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) remote_list_parser.set_defaults(func=CmdRemoteList) diff --git a/dvc/command/remove.py b/dvc/command/remove.py index 13faf5aa9..2d366f8d8 100644 --- a/dvc/command/remove.py +++ b/dvc/command/remove.py @@ -1,9 +1,11 @@ from __future__ import unicode_literals +import argparse + import dvc.prompt as prompt import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdRemove(CmdBase): @@ -38,15 +40,13 @@ class CmdRemove(CmdBase): def add_parser(subparsers, parent_parser): - REMOVE_HELP = ( - "Remove outputs of DVC file.\n" - "documentation: https://man.dvc.org/remove" - ) + REMOVE_HELP = "Remove outputs of DVC file." remove_parser = subparsers.add_parser( "remove", parents=[parent_parser], - description=REMOVE_HELP, + description=append_doc_link(REMOVE_HELP, "remove"), help=REMOVE_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) remove_parser_group = remove_parser.add_mutually_exclusive_group() remove_parser_group.add_argument( diff --git a/dvc/command/repro.py b/dvc/command/repro.py index 20ed4a5b6..ba5a17ae0 100644 --- a/dvc/command/repro.py +++ b/dvc/command/repro.py @@ -1,9 +1,10 @@ from __future__ import unicode_literals +import argparse import os import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link from dvc.command.metrics import show_metrics from dvc.command.status import CmdDataStatus from dvc.exceptions import DvcException @@ -53,18 +54,18 @@ class CmdRepro(CmdBase): def add_parser(subparsers, parent_parser): - REPRO_HELP = ( - "Reproduce DVC file. Default file name - 'Dvcfile'.\n" - "documentation: https://man.dvc.org/repro" - ) + REPRO_HELP = "Check for changes and reproduce DVC file and dependencies." repro_parser = subparsers.add_parser( "repro", parents=[parent_parser], - description=REPRO_HELP, + description=append_doc_link(REPRO_HELP, "repro"), help=REPRO_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) repro_parser.add_argument( - "targets", nargs="*", help="DVC file to reproduce." + "targets", + nargs="*", + help="DVC file to reproduce (default - 'Dvcfile').", ) repro_parser.add_argument( "-f", diff --git a/dvc/command/root.py b/dvc/command/root.py index 27d9121aa..da154ad97 100644 --- a/dvc/command/root.py +++ b/dvc/command/root.py @@ -1,9 +1,10 @@ from __future__ import unicode_literals +import argparse import os import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdRoot(CmdBase): @@ -16,11 +17,12 @@ class CmdRoot(CmdBase): def add_parser(subparsers, parent_parser): - ROOT_HELP = ( - "Relative path to repo's directory.\n" - "documentation: https://man.dvc.org/root" - ) + ROOT_HELP = "Relative path to the repository's directory." root_parser = subparsers.add_parser( - "root", parents=[parent_parser], description=ROOT_HELP, help=ROOT_HELP + "root", + parents=[parent_parser], + description=append_doc_link(ROOT_HELP, "root"), + help=ROOT_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) root_parser.set_defaults(func=CmdRoot) diff --git a/dvc/command/run.py b/dvc/command/run.py index 1c9185a5f..619dea51f 100644 --- a/dvc/command/run.py +++ b/dvc/command/run.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import argparse import dvc.logger as logger -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link from dvc.exceptions import DvcException @@ -78,13 +78,13 @@ class CmdRun(CmdBase): def add_parser(subparsers, parent_parser): - RUN_HELP = ( - "Generate a stage file from a given " - "command and execute the command.\n" - "documentation: https://man.dvc.org/run" - ) + RUN_HELP = "Generate a stage file from a command and execute the command." run_parser = subparsers.add_parser( - "run", parents=[parent_parser], description=RUN_HELP, help=RUN_HELP + "run", + parents=[parent_parser], + description=append_doc_link(RUN_HELP, "run"), + help=RUN_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) run_parser.add_argument( "-d", diff --git a/dvc/command/unprotect.py b/dvc/command/unprotect.py index 7ab448296..98716952f 100644 --- a/dvc/command/unprotect.py +++ b/dvc/command/unprotect.py @@ -1,8 +1,10 @@ from __future__ import unicode_literals +import argparse + import dvc.logger as logger from dvc.exceptions import DvcException -from dvc.command.base import CmdBase +from dvc.command.base import CmdBase, append_doc_link class CmdUnprotect(CmdBase): @@ -18,15 +20,13 @@ class CmdUnprotect(CmdBase): def add_parser(subparsers, parent_parser): - UNPROTECT_HELP = ( - "Unprotect data file/directory.\n" - "documentation: https://man.dvc.org/unprotect" - ) + UNPROTECT_HELP = "Unprotect a data file/directory." unprotect_parser = subparsers.add_parser( "unprotect", parents=[parent_parser], - description=UNPROTECT_HELP, + description=append_doc_link(UNPROTECT_HELP, "unprotect"), help=UNPROTECT_HELP, + formatter_class=argparse.RawDescriptionHelpFormatter, ) unprotect_parser.add_argument( "targets", nargs="+", help="Data files/directory."