MCPcopy
hub / github.com/docker/docker-agent / runAliasRemoveCommand

Function runAliasRemoveCommand

cmd/root/alias.go:287–311  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

285}
286
287func runAliasRemoveCommand(cmd *cobra.Command, args []string) (commandErr error) {
288 telemetry.TrackCommand(cmd.Context(), "alias", append([]string{"remove"}, args...))
289 defer func() {
290 telemetry.TrackCommandError(cmd.Context(), "alias", append([]string{"remove"}, args...), commandErr)
291 }()
292
293 out := cli.NewPrinter(cmd.OutOrStdout())
294 name := args[0]
295
296 cfg, err := userconfig.Load()
297 if err != nil {
298 return fmt.Errorf("failed to load config: %w", err)
299 }
300
301 if !cfg.DeleteAlias(name) {
302 return fmt.Errorf("alias '%s' not found", name)
303 }
304
305 if err := cfg.Save(); err != nil {
306 return fmt.Errorf("failed to save config: %w", err)
307 }
308
309 out.Printf("Alias '%s' removed successfully\n", name)
310 return nil
311}

Callers

nothing calls this directly

Calls 8

PrintfMethod · 0.95
TrackCommandFunction · 0.92
TrackCommandErrorFunction · 0.92
NewPrinterFunction · 0.92
LoadFunction · 0.92
ContextMethod · 0.80
DeleteAliasMethod · 0.80
SaveMethod · 0.80

Tested by

no test coverage detected