(packages []string)
| 41 | } |
| 42 | |
| 43 | func installer(packages []string) { |
| 44 | // Hard-coded variables, will add functionality to change these via flags |
| 45 | log.DecreasePadding() |
| 46 | log.Info("Installing packages...") |
| 47 | log.IncreasePadding() |
| 48 | for i := 0; i < len(packages); i++ { |
| 49 | log.Infof(packages[i]) |
| 50 | } |
| 51 | log.ResetPadding() |
| 52 | log.Info("Downloading packages...") |
| 53 | log.IncreasePadding() |
| 54 | org := utils.GetEnv("ORG_OVERRIDE", "catppuccin") |
| 55 | var success []string |
| 56 | for i := 0; i < len(packages); i++ { |
| 57 | repo := packages[i] |
| 58 | // Attempt to get the .catppuccin.yaml |
| 59 | rc := fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/main/.catppuccin.yaml", org, repo) |
| 60 | res, err := http.Get(rc) |
| 61 | if err != nil { |
| 62 | log.Fatalf("Could not make GET request") |
| 63 | } |
| 64 | if res.StatusCode != 200 { |
| 65 | log.Errorf("%s does not have a .catppuccin.yaml.", repo) |
| 66 | } else { |
| 67 | success = append(success, string(repo)) |
| 68 | } |
| 69 | } |
| 70 | log.ResetPadding() |
| 71 | log.IncreasePadding() |
| 72 | log.Info("Checking for installed packages:") |
| 73 | programs := []structs.Program{} |
| 74 | programLocations := []string{} |
| 75 | programNames := []string{} |
| 76 | comments := []string{} |
| 77 | |
| 78 | for i := 0; i < len(success); i++ { |
| 79 | rc := "https://raw.githubusercontent.com/" + org + "/" + success[i] + "/main/.catppuccin.yaml" |
| 80 | res, err := http.Get(rc) |
| 81 | if err != nil { |
| 82 | log.Errorf("Could not make GET request") |
| 83 | } |
| 84 | defer res.Body.Close() |
| 85 | body, err := io.ReadAll(res.Body) |
| 86 | if err != nil { |
| 87 | log.Errorf("Failed to read body") |
| 88 | } else { |
| 89 | ctprc, err := structs.UnmarshalProgram(body) |
| 90 | if err != nil { |
| 91 | log.Errorf(".catppuccin.yaml couldn't be unmarshaled correctly. Some data may be corrupted.\n") |
| 92 | } |
| 93 | var InstallDir string |
| 94 | switch runtime.GOOS { |
| 95 | case "windows": |
| 96 | InstallDir = utils.HandleDir(ctprc.Installation.InstallLocation.Windows) |
| 97 | case "linux": |
| 98 | InstallDir = utils.HandleDir(ctprc.Installation.InstallLocation.Linux) |
| 99 | case "darwin": |
| 100 | InstallDir = utils.HandleDir(ctprc.Installation.InstallLocation.Macos) |
no test coverage detected