MCPcopy Index your code
hub / github.com/bootdotdev/bootdev / requireUpdated

Function requireUpdated

cmd/root.go:118–144  ·  view source on GitHub ↗

Call this function at the beginning of a command handler if you want to require the user to update their CLI first.

(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

116// Call this function at the beginning of a command handler
117// if you want to require the user to update their CLI first.
118func requireUpdated(cmd *cobra.Command, args []string) {
119 info := version.FromContext(cmd.Context())
120 if info == nil {
121 if !promptToContinue(
122 "WARNING: Can't get version info",
123 "Unable to check whether your bootdev CLI is up to date.",
124 "Continue anyway?",
125 ) {
126 os.Exit(1)
127 }
128 return
129 }
130 if info.FailedToFetch != nil {
131 if !promptToContinue(
132 "WARNING: Can't get version info",
133 fmt.Sprintf("Unable to check whether your bootdev CLI is up to date: %s", info.FailedToFetch.Error()),
134 "Continue anyway?",
135 ) {
136 os.Exit(1)
137 }
138 return
139 }
140 if info.IsUpdateRequired {
141 info.PromptUpdateIfAvailable()
142 os.Exit(1)
143 }
144}
145
146func promptToContinue(title string, message string, prompt string) bool {
147 fmt.Fprintln(os.Stderr, title)

Callers

nothing calls this directly

Calls 3

FromContextFunction · 0.92
promptToContinueFunction · 0.85

Tested by

no test coverage detected