* feat(cli): improve agent ergonomics * fix(cli): address code review findings - Fix nil pointer dereference in confirmDestructive when flags is nil - Deduplicate dry-run logic by delegating to dryRunExit - Remove deprecated net.Error.Temporary() call (dead since Go 1.18) - Add unit tests for resolveTasklistID and resolveCalendarID Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve PR #201 conflicts and follow-ups (#201) (thanks @salmonumbrella) * fix: resolve rebase fallout for PR #201 landing (#201) (thanks @salmonumbrella) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/steipete/gogcli/internal/outfmt"
|
|
"github.com/steipete/gogcli/internal/ui"
|
|
)
|
|
|
|
type ClassroomProfileCmd struct {
|
|
Get ClassroomProfileGetCmd `cmd:"" default:"withargs" help:"Get a user profile"`
|
|
}
|
|
|
|
type ClassroomProfileGetCmd struct {
|
|
UserID string `arg:"" name:"userId" optional:"" help:"User ID or email (default: me)"`
|
|
}
|
|
|
|
func (c *ClassroomProfileGetCmd) Run(ctx context.Context, flags *RootFlags) error {
|
|
u := ui.FromContext(ctx)
|
|
account, err := requireAccount(flags)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
userID := strings.TrimSpace(c.UserID)
|
|
if userID == "" {
|
|
userID = "me"
|
|
}
|
|
|
|
svc, err := newClassroomService(ctx, account)
|
|
if err != nil {
|
|
return wrapClassroomError(err)
|
|
}
|
|
|
|
profile, err := svc.UserProfiles.Get(userID).Context(ctx).Do()
|
|
if err != nil {
|
|
return wrapClassroomError(err)
|
|
}
|
|
|
|
if outfmt.IsJSON(ctx) {
|
|
return outfmt.WriteJSON(ctx, os.Stdout, map[string]any{"profile": profile})
|
|
}
|
|
|
|
u.Out().Printf("id\t%s", profile.Id)
|
|
u.Out().Printf("email\t%s", profile.EmailAddress)
|
|
u.Out().Printf("name\t%s", profileName(profile))
|
|
u.Out().Printf("verified_teacher\t%t", profile.VerifiedTeacher)
|
|
if profile.PhotoUrl != "" {
|
|
u.Out().Printf("photo_url\t%s", profile.PhotoUrl)
|
|
}
|
|
return nil
|
|
}
|