forked from micromdm/micromdm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_dep_account.go
More file actions
38 lines (33 loc) · 925 Bytes
/
Copy pathget_dep_account.go
File metadata and controls
38 lines (33 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"context"
"flag"
"fmt"
"os"
"text/tabwriter"
)
type depaccountTableOutput struct{ w *tabwriter.Writer }
func (out *depaccountTableOutput) BasicHeader() {
fmt.Fprintf(out.w, "OrgName\tOrgPhone\tOrgEmail\tServerName\n")
}
func (out *depaccountTableOutput) BasicFooter() {
out.w.Flush()
}
func (cmd *getCommand) getDEPAccount(args []string) error {
flagset := flag.NewFlagSet("dep-account", flag.ExitOnError)
flagset.Usage = usageFor(flagset, "mdmctl get dep-account [flags]")
if err := flagset.Parse(args); err != nil {
return err
}
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
out := &depaccountTableOutput{w}
out.BasicHeader()
defer out.BasicFooter()
ctx := context.Background()
resp, err := cmd.depsvc.GetAccountInfo(ctx)
if err != nil {
return err
}
fmt.Fprintf(out.w, "%s\t%s\t%s\t%s\n", resp.OrgName, resp.OrgPhone, resp.OrgEmail, resp.ServerName)
return nil
}