Skip to content

Improve drenv CLI help with descriptions and examples - #2688

Open
SuchiBhargav wants to merge 1 commit into
RamenDR:mainfrom
SuchiBhargav:drenv_cli_help
Open

Improve drenv CLI help with descriptions and examples #2688
SuchiBhargav wants to merge 1 commit into
RamenDR:mainfrom
SuchiBhargav:drenv_cli_help

Conversation

@SuchiBhargav

@SuchiBhargav SuchiBhargav commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Improve the drenv CLI help output by adding descriptive text and
usage examples to make commands easier to understand and use.

Changes

  • Added a short description for commands to clearly explain their purpose.
  • Added detailed help text describing each command's behavior.
  • Included common usage examples in the help output.
  • Improved the overall readability and discoverability of the CLI help.

Why

The previous help output primarily displayed the command syntax and
available options, requiring users to refer to external documentation
to understand a command's purpose and usage. This change makes the
built-in help more informative and aligns it more closely with the
user experience provided by mature CLIs such as kubectl.

Example

% drenv start -h
usage: drenv start [-h] [--logfile LOGFILE] [--name-prefix PREFIX] [--skip-tests] [--skip-addons]
                   [--max-workers N] [--timeout TIMEOUT] [--local-registry] [--dns-mode {auto,static,host}]
                   envfile

Start the DR environment defined in the envfile. Creates minikube clusters for each profile (if they don't
already exist), deploys all addons, and runs addon tests. The command is idempotent — rerunning it on an          
already-running environment is safe. Run drenv setup once before the first start to prepare the host.

Examples:
  # Start the regional-dr.yaml environemnt
  drenv start test/envs/regional-dr.yaml

positional arguments:
  envfile               path to environment file

options:
  -h, --help            show this help message and exit
  --logfile LOGFILE     path to logfile (default 'drenv.log')
  --name-prefix PREFIX  prefix profile names
  --skip-tests          Do not run addons 'test' hooks
  --skip-addons         Do not run addons 'start' hooks
  --max-workers N       maximum number of workers per profile
  --timeout TIMEOUT     time in seconds to wait until clsuter is started
  --local-registry      Use local registry. For lima provider the local registry must have the k8s images for
                        kubeadm. See registry/README.md for more info.
  --dns-mode {auto,static,host}
                        DNS configuration mode. 'auto' detects managed Macs and uses 'static' if needed.
                        'static' configures public DNS servers (8.8.8.8, 1.1.1.1). 'host' uses the host resolver
                        (default for minikube, may not work on managed Macs).

Fixes #2690

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Improved command-line help for delete, registry-cache, and stress-test.
    • Added clearer descriptions, usage examples, epilogs, and improved formatting for subcommands.
    • Expanded help output to make command options and expected usage easier to understand.
    • Updated command registration to support richer, consistently formatted help content across the CLI.

Walkthrough

The drenv CLI now supports richer help metadata through add_command. The delete, registry-cache, and stress-test command trees include descriptions, examples, epilogs, and raw-description formatting.

Changes

CLI help enhancements

Layer / File(s) Summary
Extended command registration
test/drenv/__main__.py
add_command now accepts and forwards description, epilog, and formatter options.
Command and subcommand help text
test/drenv/__main__.py
The selected commands and subcommands now provide expanded descriptions, usage examples, epilogs, and raw-description formatting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • RamenDR/ramen#2681: Both PRs update test/drenv/__main__.py with CLI help enhancements and expanded add_command options.

Suggested reviewers: nirs, raghavendra-talur, parikshithb

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changes improve delete help but do not address the linked issue's required start and setup descriptions and examples [#2690]. Add the required detailed descriptions and usage examples for the start and setup commands, including their relationship and responsibilities.
Out of Scope Changes check ⚠️ Warning Help changes for registry-cache and stress-test are outside the linked issue's stated scope of start, setup, and delete [#2690]. Remove unrelated registry-cache and stress-test help changes, or link issues that explicitly require those updates.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely summarizes the main change to improve drenv CLI help with descriptions and examples.
Description check ✅ Passed The description directly explains the CLI help improvements, examples, purpose, and related issue.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/drenv/__main__.py`:
- Around line 235-237: Fix the `stress-test run` example in the help text near
the `add_command` registration: include the required environment-file positional
argument in the example, unless `stress.run` is intentionally environment-file
independent, in which case configure its `add_command` call with `envfile=False`
and keep the shorter example.
- Around line 316-328: Rename the add_command parameter from help to help_text
to avoid shadowing Python’s built-in, update all add_command callers to pass
help_text, and preserve the parser configuration by forwarding it as
help=help_text to sp.add_parser.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e89858cd-c3d0-4cf6-b78c-9d5bf1fb917c

📥 Commits

Reviewing files that changed from the base of the PR and between c3e2da7 and 330a937.

📒 Files selected for processing (1)
  • test/drenv/__main__.py
📜 Review details
🧰 Additional context used
🪛 Ruff (0.16.0)
test/drenv/__main__.py

[error] 320-320: Function argument help is shadowing a Python builtin

(A002)

🔇 Additional comments (1)
test/drenv/__main__.py (1)

144-160: LGTM!

Also applies to: 181-192, 201-206, 221-224, 228-234, 238-253, 281-286, 299-304, 329-332, 799-799

Comment thread test/drenv/__main__.py
Comment on lines +235 to +237
"Examples:\n"
" drenv stress-test run\n"
" drenv stress-test report out"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fix the stress-test run example.

add_command defaults envfile=True, and the run subcommand does not override it. The parser therefore requires a positional envfile. Line 236 omits that argument, so copying the example produces an argparse error.

Use an example that includes the environment file. If stress.run does not need an environment file, set envfile=False in the add_command call instead.

Proposed help-text fix
-            "  drenv stress-test run\n"
+            "  drenv stress-test run envs/regional-dr.yaml\n"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"Examples:\n"
" drenv stress-test run\n"
" drenv stress-test report out"
"Examples:\n"
" drenv stress-test run envs/regional-dr.yaml\n"
" drenv stress-test report out"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/drenv/__main__.py` around lines 235 - 237, Fix the `stress-test run`
example in the help text near the `add_command` registration: include the
required environment-file positional argument in the example, unless
`stress.run` is intentionally environment-file independent, in which case
configure its `add_command` call with `envfile=False` and keep the shorter
example.

Comment thread test/drenv/__main__.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/drenv/__main__.py`:
- Around line 799-804: Resolve the conflict at the module entry point in
test/drenv/__main__.py by removing all Git conflict markers and retaining
exactly one main() invocation, so the CLI executes once and the file remains
valid Python.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0e7b69b6-55f4-4f31-887a-c9018a749cc3

📥 Commits

Reviewing files that changed from the base of the PR and between 330a937 and 99822e4.

📒 Files selected for processing (1)
  • test/drenv/__main__.py
📜 Review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: Golangci Lint (e2e)
  • GitHub Check: Go compatibility
  • GitHub Check: Golangci Lint (.)
  • GitHub Check: Build image
  • GitHub Check: ramendev (ubuntu-24.04, 3.10)
  • GitHub Check: Linters
  • GitHub Check: Golangci Lint (api)
  • GitHub Check: Unit tests
  • GitHub Check: ramendev (ubuntu-24.04, 3.13)
🧰 Additional context used
🪛 Ruff (0.16.1)
test/drenv/__main__.py

[warning] 799-799: Expected an indented block after if statement

(invalid-syntax)


[warning] 799-799: Expected a statement

(invalid-syntax)


[warning] 799-799: Expected a statement

(invalid-syntax)


[warning] 799-799: Expected a statement

(invalid-syntax)


[warning] 800-800: Unexpected indentation

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-802: Expected a statement

(invalid-syntax)


[warning] 802-802: Unexpected indentation

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Simple statements must be separated by newlines or semicolons

(invalid-syntax)


[warning] 804-804: Expected ,, found name

(invalid-syntax)

Comment thread test/drenv/__main__.py Outdated
Comment on lines +799 to +804
<<<<<<< HEAD
main()
=======
main()

>>>>>>> 6a991aaa (format updated)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Resolve the merge conflict before merging.

Lines 799-804 contain Git conflict markers, so Python cannot parse test/drenv/__main__.py. Remove the markers and retain exactly one main() call. Keeping both calls would execute the CLI twice.

Proposed fix
-<<<<<<< HEAD
-    main()
-=======
-    main()
-
->>>>>>> 6a991aaa (format updated)
+    main()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<<<<<<< HEAD
main()
=======
main()
>>>>>>> 6a991aaa (format updated)
main()
🧰 Tools
🪛 Ruff (0.16.1)

[warning] 799-799: Expected an indented block after if statement

(invalid-syntax)


[warning] 799-799: Expected a statement

(invalid-syntax)


[warning] 799-799: Expected a statement

(invalid-syntax)


[warning] 799-799: Expected a statement

(invalid-syntax)


[warning] 800-800: Unexpected indentation

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-801: Expected a statement

(invalid-syntax)


[warning] 801-802: Expected a statement

(invalid-syntax)


[warning] 802-802: Unexpected indentation

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Expected a statement

(invalid-syntax)


[warning] 804-804: Simple statements must be separated by newlines or semicolons

(invalid-syntax)


[warning] 804-804: Expected ,, found name

(invalid-syntax)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/drenv/__main__.py` around lines 799 - 804, Resolve the conflict at the
module entry point in test/drenv/__main__.py by removing all Git conflict
markers and retaining exactly one main() invocation, so the CLI executes once
and the file remains valid Python.

Source: Linters/SAST tools

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Improve the help output by adding detailed command descriptions,
usage information, and examples for drenv subcommands.

This makes the CLI easier to learn and reduces the need to
consult external documentation for common workflows.

Signed-off-by: Suchi <hiiamsuchi@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Comment thread test/drenv/__main__.py
help=None,
envfile=True,
description=None,
epilog=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added after the options - we want to add the example before - see the issue.

Comment thread test/drenv/__main__.py
func,
help=None,
envfile=True,
description=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the only change - the caller will add the long description and the examples.

Comment thread test/drenv/__main__.py
envfile=True,
description=None,
epilog=None,
formatter_class=argparse.HelpFormatter,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want that every command will have to set the formatter_calss. Use this internally transparently.

Comment thread test/drenv/__main__.py
"Compare the results of two stress-test output directories and\n"
"summarize the differences."
),
formatter_class=argparse.RawDescriptionHelpFormatter,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is can be use internally for all commands, or for commands with description != None

Comment thread test/drenv/__main__.py
stress.compare,
help="compare 2 stress tests",
envfile=False,
description="Compare two stress test runs.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not add new content - same as the help=

Comment thread test/drenv/__main__.py
epilog=(
"Compare the results of two stress-test output directories and\n"
"summarize the differences."
),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the description

Comment thread test/drenv/__main__.py
"comparison and reporting.\n\n"
"Examples:\n"
" drenv stress-test run\n"
" drenv stress-test report out"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using multiple lines with "\n" is messy. We can use:

        description="""
Execute repeated stress-test runs and collect results for later comparison and reporting.

Examples:
  # Description of this example
  drenv stress-test run

  # Description of this example
  drenv stress-test report out
""".strip()

Comment thread test/drenv/__main__.py
" drenv stress-test run\n"
" drenv stress-test report out"
),
formatter_class=argparse.RawDescriptionHelpFormatter,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test how this deals with long lines. We want the formatted to handle line wrapping, keeping existing structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add detailed descriptions and examples to drenv help

3 participants