MCPcopy Create free account
hub / github.com/openclaw/gogcli / Run

Method Run

internal/cmd/admin_users.go:124–201  ·  view source on GitHub ↗
(ctx context.Context, flags *RootFlags)

Source from the content-addressed store, hash-verified

122}
123
124func (c *AdminUsersGetCmd) Run(ctx context.Context, flags *RootFlags) error {
125 account, err := requireAdminAccount(flags)
126 if err != nil {
127 return err
128 }
129
130 userEmail := strings.TrimSpace(c.UserEmail)
131 if userEmail == "" {
132 return usage("user email required")
133 }
134
135 svc, err := adminDirectoryService(ctx, account)
136 if err != nil {
137 return wrapAdminDirectoryError(err, account)
138 }
139
140 user, err := svc.Users.Get(userEmail).Context(ctx).Do()
141 if err != nil {
142 return wrapAdminDirectoryError(err, account)
143 }
144
145 if outfmt.IsJSON(ctx) {
146 type item struct {
147 Email string `json:"email"`
148 Name string `json:"name,omitempty"`
149 GivenName string `json:"givenName,omitempty"`
150 FamilyName string `json:"familyName,omitempty"`
151 Suspended bool `json:"suspended"`
152 Admin bool `json:"admin"`
153 Aliases []string `json:"aliases,omitempty"`
154 OrgUnitPath string `json:"orgUnitPath,omitempty"`
155 Creation string `json:"creationTime,omitempty"`
156 LastLogin string `json:"lastLoginTime,omitempty"`
157 }
158 var aliases []string
159 if user.Aliases != nil {
160 aliases = user.Aliases
161 }
162 name := ""
163 givenName := ""
164 familyName := ""
165 if user.Name != nil {
166 name = user.Name.FullName
167 givenName = user.Name.GivenName
168 familyName = user.Name.FamilyName
169 }
170 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), item{
171 Email: user.PrimaryEmail,
172 Name: name,
173 GivenName: givenName,
174 FamilyName: familyName,
175 Suspended: user.Suspended,
176 Admin: user.IsAdmin,
177 Aliases: aliases,
178 OrgUnitPath: user.OrgUnitPath,
179 Creation: user.CreationTime,
180 LastLogin: user.LastLoginTime,
181 })

Callers

nothing calls this directly

Calls 10

IsJSONFunction · 0.92
WriteJSONFunction · 0.92
requireAdminAccountFunction · 0.85
usageFunction · 0.85
adminDirectoryServiceFunction · 0.85
wrapAdminDirectoryErrorFunction · 0.85
stdoutWriterFunction · 0.85
tableWriterFunction · 0.85
DoMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected