captureUpdateFlags reads the --default, --fallback, and --description flags only when explicitly set and stores their values in the package-level pointer options. This avoids treating their zero values as an intention to update.
(cmd *cobra.Command)
| 155 | // stores their values in the package-level pointer options. This avoids treating their zero |
| 156 | // values as an intention to update. |
| 157 | func captureUpdateFlags(cmd *cobra.Command) error { |
| 158 | if f := cmd.Flags().Lookup("default"); f != nil && f.Changed { |
| 159 | v, err := cmd.Flags().GetBool("default") |
| 160 | if err != nil { |
| 161 | return err |
| 162 | } |
| 163 | isDefaultCASBackendUpdateOption = &v |
| 164 | } |
| 165 | |
| 166 | if f := cmd.Flags().Lookup("fallback"); f != nil && f.Changed { |
| 167 | v, err := cmd.Flags().GetBool("fallback") |
| 168 | if err != nil { |
| 169 | return err |
| 170 | } |
| 171 | isFallbackCASBackendUpdateOption = &v |
| 172 | } |
| 173 | |
| 174 | if f := cmd.Flags().Lookup("description"); f != nil && f.Changed { |
| 175 | v, err := cmd.Flags().GetString("description") |
| 176 | if err != nil { |
| 177 | return err |
| 178 | } |
| 179 | descriptionCASBackendUpdateOption = &v |
| 180 | } |
| 181 | |
| 182 | return nil |
| 183 | } |
| 184 | |
| 185 | // handleDefaultUpdateConfirmation centralizes the confirmation logic when the --default flag |
| 186 | // is provided. It returns (true, nil) when it's ok to proceed, (false, nil) when the user |
no outgoing calls
no test coverage detected