mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-13 05:45:41 +08:00
Add more logic to the way code is organized. /pkg -- library code not directly connected to micromdm /mdm -- packages meant for the services devices interract with. The MDM protocol. /dep -- DEP API and related packages. /platform -- Core APIs the server provides. Commands API, Devices API, queue, pubsub etc. /workflow -- Packages/API that build on top of platform. Today that's the webhook package. Depending on what ends up here, the workflow folder might become its own repository.
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"text/tabwriter"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/micromdm/micromdm/platform/apiserver/list"
|
|
)
|
|
|
|
type usersTableOutput struct{ w *tabwriter.Writer }
|
|
|
|
func (out *usersTableOutput) BasicHeader() {
|
|
fmt.Fprintf(out.w, "UUID\tUDID\tUserID\tUserShortName\tUserLongName\n")
|
|
}
|
|
|
|
func (out *usersTableOutput) BasicFooter() {
|
|
out.w.Flush()
|
|
}
|
|
|
|
func (cmd *getCommand) getUsers(args []string) error {
|
|
flagset := flag.NewFlagSet("users", flag.ExitOnError)
|
|
flagset.Usage = usageFor(flagset, "mdmctl get users [flags]")
|
|
if err := flagset.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
|
|
w := tabwriter.NewWriter(os.Stderr, 0, 4, 2, ' ', 0)
|
|
out := &usersTableOutput{w}
|
|
out.BasicHeader()
|
|
defer out.BasicFooter()
|
|
|
|
users, err := cmd.list.ListUsers(context.TODO(), list.ListUsersOption{})
|
|
if err != nil {
|
|
return errors.Wrap(err, "list users")
|
|
}
|
|
|
|
for _, u := range users {
|
|
fmt.Fprintf(out.w, "%s\t%s\t%s\t%v\t%s\n", u.UUID, u.UDID, u.UserID, u.UserShortname, u.UserLongname)
|
|
}
|
|
|
|
return nil
|
|
}
|