MCPcopy
hub / github.com/basecamp/once / run

Method run

internal/command/background_remove.go:30–56  ·  view source on GitHub ↗

Private

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

Source from the content-addressed store, hash-verified

28// Private
29
30func (b *backgroundUninstallCommand) run(cmd *cobra.Command, args []string) error {
31 if os.Getuid() != 0 {
32 return fmt.Errorf("must be run as root")
33 }
34
35 ctx := context.Background()
36 namespace := namespaceFlag(cmd)
37
38 svc, err := service.New()
39 if err != nil {
40 return err
41 }
42
43 serviceName := namespace + backgroundServiceSuffix
44
45 if !svc.IsInstalled(serviceName) {
46 fmt.Printf("Service %s is not installed\n", svc.ServiceName(serviceName))
47 return nil
48 }
49
50 if err := svc.Remove(ctx, serviceName); err != nil {
51 return fmt.Errorf("removing service: %w", err)
52 }
53
54 fmt.Printf("Uninstalled %s\n", svc.ServiceName(serviceName))
55 return nil
56}

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
namespaceFlagFunction · 0.85
IsInstalledMethod · 0.65
ServiceNameMethod · 0.65
RemoveMethod · 0.65

Tested by

no test coverage detected