mirror of
https://github.com/micromdm/micromdm/
synced 2026-06-29 17:55:37 +08:00
The new remove devices command takes a UDID or list of UDIDs as input and calls the devices delete endpoint. Since serial number isn't strictly required by the spec it seemed to make more sense to keep the remove working with only UDIDs. The get devices command with a serial number filter can always be used to look up a UDID from a serial number.
36 lines
745 B
Go
36 lines
745 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (cmd *removeCommand) removeDevices(args []string) error {
|
|
flagset := flag.NewFlagSet("remove-devices", flag.ExitOnError)
|
|
var (
|
|
flIdentifier = flagset.String("udid", "", "device UDID, optionally comma separated")
|
|
)
|
|
flagset.Usage = usageFor(flagset, "mdmctl remove devices [flags]")
|
|
if err := flagset.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
|
|
if *flIdentifier == "" {
|
|
return errors.New("bad input: device UDID must be provided")
|
|
}
|
|
|
|
ctx := context.Background()
|
|
err := cmd.devicesvc.RemoveDevices(ctx, strings.Split(*flIdentifier, ","))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Printf("removed devices(s): %s\n", *flIdentifier)
|
|
|
|
return nil
|
|
}
|