From b8b5ebd89a6bf466cd502755c033e23474b6a9d5 Mon Sep 17 00:00:00 2001 From: Muhtasim-Munif-Fahim Date: Thu, 13 Aug 2026 12:56:42 +0600 Subject: [PATCH 1/2] fix: show complete help text for `dagshub repo create` `dagshub repo --help` derived the command listing from the first line of the `create` docstring, which is "create a repo and optionally:". The listing therefore ended on a dangling colon and read as truncated output: Commands: create create a repo and optionally: Giving the command an explicit `short_help` makes the listing a complete sentence. The long help was mangled too. The bullet list and the examples are pre-formatted, but nothing marked them as such, so click rewrapped them into run-on paragraphs and collapsed the indentation: - upload files to 'data' from a URL dir using `-u` flag. .zip and .tar files are extracted, other formats copied as is. Adding click's `\b` no-rewrap markers keeps the structure intact. Adds tests/common/test_cli.py, the first CLI test in the suite, asserting the listing carries a complete summary and that the bullets and examples survive rendering. Both fail without this change. Fixes #310 Co-Authored-By: Claude Opus 5 --- dagshub/common/cli.py | 22 +++++++++++++--------- tests/common/test_cli.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 tests/common/test_cli.py diff --git a/dagshub/common/cli.py b/dagshub/common/cli.py index e5bafe67..831d68bc 100644 --- a/dagshub/common/cli.py +++ b/dagshub/common/cli.py @@ -327,7 +327,7 @@ def repo(): pass -@repo.command() +@repo.command(short_help="Create a repo, optionally uploading data to it and cloning it locally") @click.argument("repo_name") @click.option("-u", "--upload-data", help="Upload data from specified url to new repository") @click.option("-c", "--clone", is_flag=True, help="Clone repository locally") @@ -336,17 +336,21 @@ def repo(): @click.pass_context def create(ctx, repo_name, upload_data, clone, verbose, quiet): """ - create a repo and optionally: + Create a repo and optionally: - - upload files to 'data' from a URL dir using `-u` flag. .zip and .tar files are extracted, - other formats copied as is. + \b + - upload files to 'data' from a URL dir using the `-u` flag. + .zip and .tar files are extracted, other formats are copied as is. + - clone the repo locally using the `--clone` flag. - - clone the repo locally using `--clone` flag + \b + Example 1: + dagshub repo create mytutorial -u "http://example.com/data.csv" --clone - example 1: dagshub repo create mytutorial -u "http://example.com/data.csv" --clone - - example 2: dagshub --host "https://www.dagshub.com" - repo create mytutorial2 -u "http://0.0.0.0:8080/index.html" --clone --verbose + \b + Example 2: + dagshub --host "https://www.dagshub.com" repo create mytutorial2 + -u "http://0.0.0.0:8080/index.html" --clone --verbose """ config.quiet = quiet or ctx.obj["quiet"] diff --git a/tests/common/test_cli.py b/tests/common/test_cli.py new file mode 100644 index 00000000..ccc3e7be --- /dev/null +++ b/tests/common/test_cli.py @@ -0,0 +1,36 @@ +from click.testing import CliRunner + +from dagshub.common.cli import cli + + +def _help(*args): + result = CliRunner().invoke(cli, [*args, "--help"]) + assert result.exit_code == 0, result.output + return result.output + + +def test_repo_group_help_lists_a_complete_summary_for_create(): + """ + The command listing used to be built from the first line of the docstring, + which ended in a colon and read as truncated output. + """ + output = _help("repo") + + assert "Create a repo, optionally uploading data to it and cloning it" in output + # The dangling summary the listing used to end on. + assert "create a repo and optionally:" not in output + + +def test_repo_create_help_keeps_its_structure(): + """ + The bullet list and the examples are pre-formatted, so click must not + rewrap them into a single run-on paragraph. + """ + output = _help("repo", "create") + + assert "- upload files to 'data' from a URL dir using the `-u` flag." in output + assert "- clone the repo locally using the `--clone` flag." in output + assert "Example 1:" in output + assert "Example 2:" in output + # The rewrapped remnant of the un-escaped bullet. + assert "are extracted, other formats" not in output From 7c559798d5eb0138f7907852c5e7e9b94935c5c4 Mon Sep 17 00:00:00 2001 From: Muhtasim-Munif-Fahim Date: Sat, 15 Aug 2026 11:15:12 +0600 Subject: [PATCH 2/2] docs: say "a file from a URL", and assert the rendered help structure Two points from review. The `-u` description said "from a URL dir", which I carried over from the original text. It is wrong: `upload_data` is passed straight to `http_request("GET", upload_data)` and the downloaded name comes from `os.path.basename(urlparse(upload_data).path)`. That is a single file, and both examples use one. "dir" invites passing a directory listing URL, which does not work. The tests checked that fragments appeared somewhere in the output, which a later rewrap could satisfy while breaking the layout the escapes exist to protect. They now assert whole lines, including indentation and the complete example command, so a regression in the formatting fails rather than passes. Co-Authored-By: Claude Opus 5 --- dagshub/common/cli.py | 2 +- tests/common/test_cli.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dagshub/common/cli.py b/dagshub/common/cli.py index 831d68bc..e6749ca6 100644 --- a/dagshub/common/cli.py +++ b/dagshub/common/cli.py @@ -339,7 +339,7 @@ def create(ctx, repo_name, upload_data, clone, verbose, quiet): Create a repo and optionally: \b - - upload files to 'data' from a URL dir using the `-u` flag. + - upload a file to 'data' from a URL using the `-u` flag. .zip and .tar files are extracted, other formats are copied as is. - clone the repo locally using the `--clone` flag. diff --git a/tests/common/test_cli.py b/tests/common/test_cli.py index ccc3e7be..fd197260 100644 --- a/tests/common/test_cli.py +++ b/tests/common/test_cli.py @@ -28,9 +28,20 @@ def test_repo_create_help_keeps_its_structure(): """ output = _help("repo", "create") - assert "- upload files to 'data' from a URL dir using the `-u` flag." in output - assert "- clone the repo locally using the `--clone` flag." in output - assert "Example 1:" in output - assert "Example 2:" in output + # Assert the rendered structure, not just that fragments appear somewhere: + # a later rewrap could satisfy substring checks while breaking the layout. + lines = [line.rstrip() for line in output.splitlines()] + + assert " - upload a file to 'data' from a URL using the `-u` flag." in lines + assert " .zip and .tar files are extracted, other formats are copied as is." in lines + assert " - clone the repo locally using the `--clone` flag." in lines + + assert " Example 1:" in lines + assert ( + ' dagshub repo create mytutorial -u "http://example.com/data.csv" --clone' + in lines + ) + assert " Example 2:" in lines + # The rewrapped remnant of the un-escaped bullet. assert "are extracted, other formats" not in output