A terminal client for Tangled, the git forge built on AT Protocol.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344package cli
import ( "github.com/alyraffauf/tg/internal/app" "github.com/spf13/cobra")
func newPRViewCommand(service *app.Service) *cobra.Command { var repository string
command := &cobra.Command{ Use: "view <rkey>", Short: "View a pull request for a Tangled repository", Long: `View a pull request by its rkey (the last segment of its at:// URI).
If --repo is not set, the repository is detected from the currentdirectory's git origin remote.`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() target, err := resolveTargetFlag(ctx, repository, service) if err != nil { return err } view, err := service.ViewPull(ctx, target, args[0]) if err != nil { return err } return output(cmd, view, func(view *app.ViewResult) { fields := []detailField{ {"Title", view.Title}, {"Status", formatDetailState(cmd.OutOrStdout(), view.State)}, {"Author", view.Author.Handle}, {"Created", view.CreatedAt}, {"Branch", view.SourceBranch + " → " + view.TargetBranch}, } renderDetail(cmd.OutOrStdout(), fields, view.Body) }) }, } command.Flags().StringVarP(&repository, "repo", "R", "", "Target repository as handle/repo") return command}