diff --git a/cmd/input.go b/cmd/input.go index 3dc191e98c..1752c96635 100644 --- a/cmd/input.go +++ b/cmd/input.go @@ -376,3 +376,14 @@ func isIntPort(val interface{}) error { return errors.New("couldn't convert to string") } + +func inputUserEmail() (email string, err error) { + prompt := &survey.Input{ + Message: "User email:", + } + if err := survey.AskOne(prompt, &email); err != nil { + return email, err + } + + return email, nil +} diff --git a/cmd/orgs.go b/cmd/orgs.go index 64a355140d..9a8206e904 100644 --- a/cmd/orgs.go +++ b/cmd/orgs.go @@ -140,17 +140,33 @@ func runOrgsShow(ctx *cmdctx.CmdContext) error { } func runOrgsInvite(ctx *cmdctx.CmdContext) error { - orgslug := ctx.Args[0] + var orgSlug, userEmail string - org, err := ctx.Client.API().GetOrganizationBySlug(orgslug) + switch len(ctx.Args) { + case 0: + org, err := selectOrganization(ctx.Client.API(), "") + if err != nil { + return err + } + orgSlug = org.Slug + userEmail, err = inputUserEmail() + if err != nil { + return err + } + case 1: + // TODO: Validity check on org + orgSlug = ctx.Args[0] + case 2: + userEmail = ctx.Args[1] + } + + org, err := ctx.Client.API().GetOrganizationBySlug(orgSlug) if err != nil { return err } - email := ctx.Args[1] - - out, err := ctx.Client.API().CreateOrganizationInvite(org.ID, email) + out, err := ctx.Client.API().CreateOrganizationInvite(org.ID, userEmail) if err != nil { return err }