Documentation
¶
Overview ¶
Package feedback provides the command to submit feedback.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FeedbackCmd = &cobra.Command{ Use: "feedback [repo-alias] [title]", Short: "Submit feedback to a contextvibes repository.", Example: ` contextvibes feedback "Tree command is slow"`, Args: cobra.MaximumNArgs(2), RunE: func(cmd *cobra.Command, args []string) error { presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr()) ctx := cmd.Context() cfg := globals.LoadedAppConfig.Feedback var repoAlias, title, body string repoAlias = cfg.DefaultRepository if len(args) == 1 { if _, ok := cfg.Repositories[args[0]]; ok { repoAlias = args[0] } else { title = args[0] } } else if len(args) == 2 { repoAlias = args[0] title = args[1] } targetRepo, ok := cfg.Repositories[repoAlias] if !ok { return fmt.Errorf("repository alias '%s' not found in configuration", repoAlias) } repoParts := strings.Split(targetRepo, "/") if len(repoParts) != 2 { return fmt.Errorf( "invalid repository format for alias '%s': expected 'owner/repo', got '%s'", repoAlias, targetRepo, ) } owner, repo := repoParts[0], repoParts[1] if title == "" { form := huh.NewForm( huh.NewGroup( huh.NewInput().Title("What is the title of your feedback?").Value(&title), huh.NewText().Title("Please provide more details (optional)").Value(&body), ), ) err := form.Run() if err != nil { return fmt.Errorf("input form failed: %w", err) } } if strings.TrimSpace(title) == "" { return errors.New("title cannot be empty") } provider, err := newProviderForRepo(ctx, globals.AppLogger, owner, repo) if err != nil { presenter.Error("Failed to initialize provider for %s: %v", targetRepo, err) return err } ghClient, _ := github.NewClient(ctx, globals.AppLogger, owner, repo) user, _ := ghClient.GetAuthenticatedUserLogin(ctx) if user == "" { user = "unknown" } contextBlock := fmt.Sprintf( "\n\n---\n**Context**\n- **CLI Version:** `%s`\n- **OS/Arch:** `%s/%s`\n- **Filed by:** @%s", globals.AppVersion, runtime.GOOS, runtime.GOARCH, user, ) finalBody := body + contextBlock newItem := workitem.WorkItem{ Title: title, Body: finalBody, Labels: []string{"feedback"}, } presenter.Summary("Submitting feedback to %s...", targetRepo) createdItem, err := provider.CreateItem(ctx, newItem) if err != nil { presenter.Error("Failed to create issue: %v", err) presenter.Advice( "Please ensure your GITHUB_TOKEN has the 'repo' scope for the '%s' repository.", targetRepo, ) return fmt.Errorf("failed to create item: %w", err) } presenter.Success("✓ Thank you! Your feedback has been submitted: %s", createdItem.URL) return nil }, }
FeedbackCmd represents the feedback command.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.