Skip to content

command: Open HTML report in default browser#408

Merged
nirs merged 4 commits intoRamenDR:mainfrom
nirs:open-in-browser
Apr 20, 2026
Merged

command: Open HTML report in default browser#408
nirs merged 4 commits intoRamenDR:mainfrom
nirs:open-in-browser

Conversation

@nirs
Copy link
Copy Markdown
Member

@nirs nirs commented Mar 31, 2026

After validation completes, the HTML report is automatically opened in
the default browser, whether the validation passed or failed. When
ramenctl is used in scripts or automation (stdout piped), the browser is
not opened. Users can override the auto-detection with
--interactive=true or --interactive=false.

Changes:

  • Add BrowseReport() function to open the HTML report in the default
    browser after a command completes.
  • Move error output from cobra handlers into the command functions so
    commands have full control over the output flow. This is needed to
    open the browser after the last error message.
  • Wire up BrowseReport() in the validate commands to open the report
    when done.
  • Add --interactive flag (default auto) to skip browser opening when
    running non-interactively. When not set explicitly, defaults to true
    if stdout is a terminal.

Example usage:

# opens browser (tty)
$ ramenctl validate clusters -o out

# no browser (pipe)
$ ramenctl validate clusters -o out | cat

# opens browser (explicit)
$ ramenctl validate clusters -o out --interactive=true | tee out.log

Based on #424 for testing.

Comment thread pkg/command/command.go Outdated
@nirs nirs force-pushed the open-in-browser branch from 0a583ab to 1874d13 Compare March 31, 2026 20:58
@nirs nirs requested a review from parikshithb March 31, 2026 21:00
@nirs nirs marked this pull request as ready for review March 31, 2026 21:10
@nirs nirs requested a review from raghavendra-talur March 31, 2026 21:18
@nirs nirs force-pushed the open-in-browser branch from 1874d13 to 31a0183 Compare March 31, 2026 21:44
@nirs nirs marked this pull request as draft March 31, 2026 23:24
@nirs nirs force-pushed the open-in-browser branch from 69b7c9f to c796d0e Compare March 31, 2026 23:27
parikshithb
parikshithb previously approved these changes Apr 9, 2026
Copy link
Copy Markdown
Member

@parikshithb parikshithb left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread pkg/command/browser.go Outdated
@nirs nirs force-pushed the open-in-browser branch from c796d0e to e011b7f Compare April 15, 2026 18:29
@nirs nirs marked this pull request as ready for review April 15, 2026 18:33
@nirs nirs force-pushed the open-in-browser branch from e011b7f to 3ba2041 Compare April 15, 2026 18:52
@nirs nirs added this to the v0.20.0 milestone Apr 16, 2026
@nirs nirs force-pushed the open-in-browser branch 2 times, most recently from 8b8c160 to ac57261 Compare April 16, 2026 12:18
@nirs nirs marked this pull request as draft April 16, 2026 13:50
@nirs nirs force-pushed the open-in-browser branch 2 times, most recently from fbadbfe to 7c40644 Compare April 19, 2026 15:55
@nirs nirs marked this pull request as ready for review April 19, 2026 15:58
@nirs nirs requested a review from parikshithb April 19, 2026 15:58
@nirs
Copy link
Copy Markdown
Member Author

nirs commented Apr 19, 2026

@parikshithb should be ready now.

parikshithb
parikshithb previously approved these changes Apr 20, 2026
Copy link
Copy Markdown
Member

@parikshithb parikshithb left a comment

Choose a reason for hiding this comment

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

Looks great!

Comment thread pkg/command/browser.go Outdated
Comment thread pkg/command/browser.go
nirs added 4 commits April 20, 2026 14:42
BrowseReport() opens the HTML report in the default browser so the user
can view it immediately. On macOS we use "open", on Windows "cmd /c
start", and on other platforms "xdg-open".

If opening fails, we log the error to the command log and show a
friendly notice suggesting to open the file manually. If xdg-open is not
installed, we also suggest installing it.

Example output when xdg-open is missing:

    ⭐ Cannot open "output/test-run.html", please open it in a browser to view the report
       Install xdg-open to open the report automatically

Also add console.Hint() for showing suggestions indented under a
previous message.

Assisted-by: Cursor/Claude Opus 4.6
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The cobra handlers called console.Fatal() to log errors and exit. This
means the command has no control over the output after an error, so it
cannot do things like opening the HTML report in the browser after
logging the failure.

Move error output to the command functions using console.Failed(), which
logs the error and returns a sentinel error. The cobra handlers call
os.Exit(1) when the command returns an error, without logging it.

console.Fatal() is replaced by console.Failed() which logs the error
and returns a sentinel error to avoid duplicating the error message.

Assisted-by: Cursor/Claude Opus 4
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Add --interactive flag (default auto) that controls interactive features
like opening the HTML report in the browser. When not set explicitly,
the flag defaults to true if stdout is a terminal, allowing scripts and
automation to suppress browser opening without extra flags.

The value is resolved in PersistentPreRun before any subcommand executes,
so all commands see the final value.

The flag will be used to open the report in a browser when validation is
done when user interaction is desired.

Assisted-by: Cursor/Claude Opus 4.6
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Always open the HTML report in the browser after validation completes,
whether successful or failed. The validation report helps understand
complex DR setups even when all checks pass.

We open the report only if user interaction is desired, based on
opts.Interactive:

    # opens browser (tty)
    $ ramenctl validate clusters -o out

    # no browser (pipe)
    $ ramenctl validate clusters -o out | cat

    # opens browser (explicit)
    $ ramenctl validate clusters -o out --interactive=true | tee out.log

Assisted-by: Cursor/Claude Opus 4.6
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
@nirs nirs force-pushed the open-in-browser branch from 45502d7 to ae2da7d Compare April 20, 2026 11:43
@nirs nirs merged commit ac1bc1f into RamenDR:main Apr 20, 2026
13 checks passed
@nirs nirs deleted the open-in-browser branch April 20, 2026 11:49
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.

2 participants