()
| 146 | } |
| 147 | |
| 148 | func cacheEnableCmd() *cobra.Command { |
| 149 | cmd := &cobra.Command{ |
| 150 | Use: "enable", |
| 151 | Short: "Enable the Devbox Nix cache for your account", |
| 152 | Long: heredoc.Doc(` |
| 153 | Sign up or log in to a Jetify Cloud account and configure Nix to use the |
| 154 | account's Nix cache. |
| 155 | |
| 156 | For more about how Devbox configures Nix, see "devbox cache configure -h". |
| 157 | `), |
| 158 | Args: cobra.ExactArgs(0), |
| 159 | RunE: func(cmd *cobra.Command, args []string) error { |
| 160 | auth, err := identity.AuthClient(identity.AuthRedirectCache) |
| 161 | if err != nil { |
| 162 | return err |
| 163 | } |
| 164 | sess, _ := auth.GetSessions() |
| 165 | needLogin := len(sess) == 0 |
| 166 | if needLogin { |
| 167 | _, err = auth.LoginFlow() |
| 168 | if err != nil { |
| 169 | return err |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | needConfigure := !nixcache.IsConfigured(cmd.Context()) |
| 174 | if needConfigure { |
| 175 | u, _ := user.Current() |
| 176 | err = nixcache.ConfigureReprompt(cmd.Context(), u.Username) |
| 177 | if err != nil { |
| 178 | return err |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | if !needConfigure && !needLogin { |
| 183 | fmt.Fprintln(cmd.OutOrStdout(), "The Devbox cache is already enabled for your account.") |
| 184 | } |
| 185 | return nil |
| 186 | }, |
| 187 | } |
| 188 | return cmd |
| 189 | } |
| 190 | |
| 191 | func cacheInfoCmd() *cobra.Command { |
| 192 | return &cobra.Command{ |
no test coverage detected