MCPcopy
hub / github.com/kopia/kopia / main

Function main

tools/gettool/gettool.go:175–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

173}
174
175func main() {
176 flag.Parse()
177
178 if *outputDir == "" {
179 log.Fatalf("--output-dir must be set")
180 }
181
182 checksums := parseEmbeddedChecksums()
183 downloadedChecksums := map[string]string{}
184
185 var errorCount int
186
187 for toolNameVersion := range strings.SplitSeq(*tool, ",") {
188 parts := strings.Split(toolNameVersion, ":")
189
190 //nolint:mnd
191 if len(parts) != 2 {
192 log.Fatalf("invalid tool spec, must be tool:version[,tool:version]")
193 }
194
195 toolName := parts[0]
196 toolVersion := parts[1]
197
198 if err := downloadTool(toolName, toolVersion, checksums, downloadedChecksums, &errorCount); err != nil {
199 log.Fatalf("unable to download %v version %v: %v", toolName, toolVersion, err)
200 }
201 }
202
203 // all good
204 if errorCount == 0 && *regenerateChecksums == "" {
205 return
206 }
207
208 // on failure print current checksums, so they can be copy/pasted as the new baseline
209 var lines []string
210
211 for k, v := range downloadedChecksums {
212 lines = append(lines, fmt.Sprintf("%v: %v", k, v))
213 }
214
215 sort.Strings(lines)
216
217 for _, l := range lines {
218 fmt.Println(l)
219 }
220
221 if *regenerateChecksums != "" {
222 if err := writeLinesToFile(lines); err != nil {
223 log.Fatal(err)
224 }
225
226 return
227 }
228
229 log.Fatalf("Error(s) encountered, see log messages above.")
230}
231
232func writeLinesToFile(lines []string) error {

Callers

nothing calls this directly

Calls 5

parseEmbeddedChecksumsFunction · 0.85
downloadToolFunction · 0.85
writeLinesToFileFunction · 0.85
ParseMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected