| 189 | } |
| 190 | |
| 191 | func cacheInfoCmd() *cobra.Command { |
| 192 | return &cobra.Command{ |
| 193 | Use: "info", |
| 194 | Short: "Output information about the nix cache", |
| 195 | Args: cobra.ExactArgs(0), |
| 196 | RunE: func(cmd *cobra.Command, args []string) error { |
| 197 | // TODO(gcurtis): We can also output info about the daemon config status |
| 198 | // here |
| 199 | caches, err := nixcache.Caches(cmd.Context()) |
| 200 | if err != nil { |
| 201 | return err |
| 202 | } |
| 203 | if len(caches) == 0 { |
| 204 | fmt.Fprintln(cmd.OutOrStdout(), "No cache configured") |
| 205 | } |
| 206 | for _, cache := range caches { |
| 207 | isReadOnly := !slices.Contains( |
| 208 | cache.GetPermissions(), |
| 209 | nixv1alpha1.Permission_PERMISSION_WRITE, |
| 210 | ) |
| 211 | fmt.Fprintf( |
| 212 | cmd.OutOrStdout(), |
| 213 | "* %s %s\n", |
| 214 | cache.GetUri(), |
| 215 | lo.Ternary(isReadOnly, "(read-only)", ""), |
| 216 | ) |
| 217 | } |
| 218 | return nil |
| 219 | }, |
| 220 | } |
| 221 | } |