mirror of
https://github.com/github/gh-stack.git
synced 2026-09-14 20:26:28 +08:00
8a9f1c86f8
* more help text for commands * improved root help * fix typo Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * updated examples for add cmd Co-authored-by: Sameen Karim <skarim@github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
|
|
"github.com/cli/go-gh/v2/pkg/browser"
|
|
"github.com/github/gh-stack/internal/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const (
|
|
feedbackURL = "https://gh.io/stacks-feedback"
|
|
feedbackFormURL = "https://gh.io/stacks-feedback-form"
|
|
)
|
|
|
|
func FeedbackCmd(cfg *config.Config) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "feedback [title]",
|
|
Short: "Submit feedback for gh-stack",
|
|
Long: "Opens a GitHub Discussion in the gh-stack repository to submit feedback. Optionally provide a title for the discussion post.",
|
|
Example: ` # Open the feedback form in your browser
|
|
$ gh stack feedback
|
|
|
|
# Open with a pre-filled title
|
|
$ gh stack feedback "My feature request"`,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return runFeedback(cfg, args)
|
|
},
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
func runFeedback(cfg *config.Config, args []string) error {
|
|
targetURL := feedbackURL
|
|
|
|
if len(args) > 0 {
|
|
title := strings.Join(args, " ")
|
|
targetURL = feedbackFormURL + "?title=" + url.QueryEscape(title)
|
|
}
|
|
|
|
b := browser.New("", cfg.Out, cfg.Err)
|
|
if err := b.Browse(targetURL); err != nil {
|
|
return err
|
|
}
|
|
|
|
cfg.Successf("Opening feedback form in your browser...")
|
|
return nil
|
|
}
|