(orgContext *OrganizationContext)
| 63 | } |
| 64 | |
| 65 | func (r *RootCmd) addOrganizationMember(orgContext *OrganizationContext) *serpent.Command { |
| 66 | cmd := &serpent.Command{ |
| 67 | Use: "add <username | user_id>", |
| 68 | Short: "Add a new member to the current organization", |
| 69 | Middleware: serpent.Chain( |
| 70 | serpent.RequireNArgs(1), |
| 71 | ), |
| 72 | Handler: func(inv *serpent.Invocation) error { |
| 73 | client, err := r.InitClient(inv) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | ctx := inv.Context() |
| 78 | organization, err := orgContext.Selected(inv, client) |
| 79 | if err != nil { |
| 80 | return err |
| 81 | } |
| 82 | user := inv.Args[0] |
| 83 | |
| 84 | _, err = client.PostOrganizationMember(ctx, organization.ID, user) |
| 85 | if err != nil { |
| 86 | return xerrors.Errorf("could not add member to organization %q: %w", organization.HumanName(), err) |
| 87 | } |
| 88 | |
| 89 | _, _ = fmt.Fprintf(inv.Stdout, "Organization member added to %q\n", organization.HumanName()) |
| 90 | return nil |
| 91 | }, |
| 92 | } |
| 93 | |
| 94 | return cmd |
| 95 | } |
| 96 | |
| 97 | func (r *RootCmd) assignOrganizationRoles(orgContext *OrganizationContext) *serpent.Command { |
| 98 | cmd := &serpent.Command{ |
no test coverage detected