Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.

Commit 7575727

Browse files
committed
feat(docs): print hyperlink to the docs when OS is not supported
1 parent 891876a commit 7575727

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

cmd/docs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ var docsCmd = &cobra.Command{
1010
Use: "docs",
1111
Short: "Open the Rewrite documentation in your browser",
1212
RunE: func(cmd *cobra.Command, args []string) error {
13-
return network.OpenURL(config.DocsURL)
13+
noColor, _ := cmd.Flags().GetBool("no-color")
14+
15+
return network.OpenURL(config.DocsURL, noColor)
1416
},
1517
}
1618

internal/network/browser.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import (
44
"fmt"
55
"os/exec"
66
"runtime"
7+
8+
"github.com/RewriteToday/cli/internal/render"
79
)
810

9-
func OpenURL(url string) error {
11+
func OpenURL(url string, noColor bool) error {
1012
var cmd string
1113
var args []string
1214

@@ -21,7 +23,9 @@ func OpenURL(url string) error {
2123
cmd = "xdg-open"
2224
args = []string{url}
2325
default:
24-
return fmt.Errorf("unsupported operating system: %s", runtime.GOOS)
26+
_, err := fmt.Println(render.Hyperlink("Go to the docs (docs.rewritetoday.com)", "https://docs.rewritetoday.com", noColor))
27+
28+
return err
2529
}
2630

2731
return exec.Command(cmd, args...).Start()

0 commit comments

Comments
 (0)