Fixes serial[s] flag to match other commands (#621)

Fixes serial[s] flag to match other commands

Fixes #618
This commit is contained in:
Nate Felton
2019-10-30 09:47:01 -04:00
committed by Victor Vrantchan
parent 19ba30018b
commit 77d46f93d7
6 changed files with 13 additions and 12 deletions

View File

@@ -3,6 +3,7 @@
* Add support for User Enrollment (#597)
* Add support for Signing Profiles (#602)
* Add support for setting APNS message expiration (#609)
* Update `mdmctl remove devices -serial` flag to be plural (now `-serials`) (#621)
## [v1.5.0](https://github.com/micromdm/micromdm/compare/v1.4.0...1.5.0) June 15 2019

View File

@@ -102,7 +102,7 @@ Examples:
mdmctl get devices
# Get a device by serial (TODO implement filtering)
mdmctl get devices -serial=C02ABCDEF
mdmctl get devices -serials=C02ABCDEF
`
fmt.Println(getUsage)
return nil
@@ -121,7 +121,7 @@ func (out *devicesTableOutput) BasicFooter() {
func (cmd *getCommand) getDevices(args []string) error {
flagset := flag.NewFlagSet("devices", flag.ExitOnError)
var (
flFilterSerials = flagset.String("serials", "", "comma separated list of serials to search")
flFilterSerials = flagset.String("serials", "", "device serial, optionally comma-separated")
)
flagset.Usage = usageFor(flagset, "mdmctl get devices [flags]")
if err := flagset.Parse(args); err != nil {

View File

@@ -22,14 +22,14 @@ func (out *depDevicesTableOutput) BasicFooter() {
func (cmd *getCommand) getDEPDevices(args []string) error {
flagset := flag.NewFlagSet("dep-devices", flag.ExitOnError)
flSerials := flagset.String("serials", "", "comma separated list of device serials")
flSerials := flagset.String("serials", "", "device serial, optionally comma-separated")
flagset.Usage = usageFor(flagset, "mdmctl get dep-devices [flags]")
if err := flagset.Parse(args); err != nil {
return err
}
if *flSerials == "" {
flagset.Usage()
return errors.New("bad input: must provide a comma separated list of DEP serials")
return errors.New("bad input: must provide a comma-separated list of DEP serials")
}
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
out := &depDevicesTableOutput{w}
@@ -42,7 +42,7 @@ func (cmd *getCommand) getDEPDevices(args []string) error {
return err
}
for _, d := range resp.Devices {
fmt.Fprintf(out.w, "%s\t%s\t%s\t%s\t%s\n", d.SerialNumber, d.Model, d.DeviceFamily, d.ProfileStatus, d.ProfileUUID)
fmt.Fprintf(out.w, "%s\t%s\t%s\t%s\t%s\n", d.SerialNumber, d.Model, d.DeviceFamily, d.ProfileStatus, d.ProfileUUID)
}
return nil
}

View File

@@ -10,7 +10,7 @@ import (
func (cmd *removeCommand) removeBlueprints(args []string) error {
flagset := flag.NewFlagSet("remove-blueprints", flag.ExitOnError)
var (
flBlueprintName = flagset.String("name", "", "name of blueprint, optionally comma separated")
flBlueprintName = flagset.String("name", "", "name of blueprint, optionally comma-separated")
)
flagset.Usage = usageFor(flagset, "mdmctl remove blueprints [flags]")
if err := flagset.Parse(args); err != nil {

View File

@@ -14,15 +14,15 @@ import (
func (cmd *removeCommand) removeDevices(args []string) error {
flagset := flag.NewFlagSet("remove-devices", flag.ExitOnError)
var (
flIdentifier = flagset.String("udid", "", "device UDID, optionally comma separated")
flSerial = flagset.String("serial", "", "device serial, optionally comma separated")
flIdentifier = flagset.String("udid", "", "device UDID, optionally comma-separated")
flSerials = flagset.String("serials", "", "device serial, optionally comma-separated")
)
flagset.Usage = usageFor(flagset, "mdmctl remove devices [flags]")
if err := flagset.Parse(args); err != nil {
return err
}
if *flIdentifier == "" && *flSerial == "" {
if *flIdentifier == "" && *flSerials == "" {
flagset.Usage()
return errors.New("bad input: device UDID or Serial must be provided")
}
@@ -31,8 +31,8 @@ func (cmd *removeCommand) removeDevices(args []string) error {
if *flIdentifier != "" {
opts.UDIDs = strings.Split(*flIdentifier, ",")
}
if *flSerial != "" {
opts.Serials = strings.Split(*flSerial, ",")
if *flSerials != "" {
opts.Serials = strings.Split(*flSerials, ",")
}
ctx := context.Background()

View File

@@ -10,7 +10,7 @@ import (
func (cmd *removeCommand) removeProfiles(args []string) error {
flagset := flag.NewFlagSet("remove-profiles", flag.ExitOnError)
var (
flIdentifier = flagset.String("id", "", "profile Identifier, optionally comma separated")
flIdentifier = flagset.String("id", "", "profile identifier, optionally comma-separated")
)
flagset.Usage = usageFor(flagset, "mdmctl remove profiles [flags]")
if err := flagset.Parse(args); err != nil {