MCPcopy Create free account
hub / github.com/AndroidPoet/playconsole-cli / runDiff

Function runDiff

cmd/playconsole-cli/commands/diff/diff.go:56–144  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

54}
55
56func runDiff(cmd *cobra.Command, args []string) error {
57 if err := cli.RequirePackage(cmd); err != nil {
58 return err
59 }
60
61 client, err := api.NewClient(cli.GetPackageName(), 60*time.Second)
62 if err != nil {
63 return err
64 }
65
66 // Get or create an edit to read current state
67 var edit *api.Edit
68 if editID != "" {
69 edit, err = client.GetEdit(editID)
70 } else {
71 edit, err = client.CreateEdit()
72 }
73 if err != nil {
74 return err
75 }
76 defer edit.Close()
77 defer func() {
78 _ = edit.Delete()
79 }()
80
81 results := make([]DiffResult, 0)
82
83 // Listings diff
84 if section == "all" || section == "listings" {
85 listingsResp, err := edit.Listings().List(
86 client.GetPackageName(), edit.ID(),
87 ).Context(edit.Context()).Do()
88 if err != nil {
89 results = append(results, DiffResult{
90 Section: "listings",
91 Status: fmt.Sprintf("error: %v", err),
92 })
93 } else {
94 summaries := make([]ListingSummary, 0, len(listingsResp.Listings))
95 for _, l := range listingsResp.Listings {
96 summaries = append(summaries, ListingSummary{
97 Language: l.Language,
98 Title: l.Title,
99 })
100 }
101 results = append(results, DiffResult{
102 Section: "listings",
103 Status: fmt.Sprintf("%d locales", len(listingsResp.Listings)),
104 Current: summaries,
105 })
106 }
107 }
108
109 // Tracks diff
110 if section == "all" || section == "tracks" {
111 tracksResp, err := edit.Tracks().List(
112 client.GetPackageName(), edit.ID(),
113 ).Context(edit.Context()).Do()

Callers

nothing calls this directly

Calls 13

GetEditMethod · 0.95
CreateEditMethod · 0.95
CloseMethod · 0.95
DeleteMethod · 0.95
ContextMethod · 0.95
ListingsMethod · 0.95
GetPackageNameMethod · 0.95
IDMethod · 0.95
TracksMethod · 0.95
RequirePackageFunction · 0.92
NewClientFunction · 0.92
GetPackageNameFunction · 0.92

Tested by

no test coverage detected