(cmd *cobra.Command, args []string)
| 54 | } |
| 55 | |
| 56 | func 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() |
nothing calls this directly
no test coverage detected