func SelectCreateOrg(c context.Context, client *api.Client, name string) (*api.OrgResult, string, bool, error) {
	// Get the list of orgs the user has access to
	orgs, err := client.Orgs.List(c)
	if err != nil {
		return nil, "", false, err
	}

	var idx int

	if name == "" {
		idx, name, err = SelectOrgPrompt(orgs)
		if err != nil {
			return nil, "", false, err
		}
	} else {
		found := false
		for i, o := range orgs {
			if o.Body.Name == name {
				found = true
				idx = i
				break
			}
		}
		if !found {
			fmt.Println(promptui.FailedValue("Org name", name))
			return nil, "", false, errs.NewExitError("Org not found")
		}
		fmt.Println(promptui.SuccessfulValue("Org name", name))
	}

	if idx == promptui.SelectedAdd {
		return nil, name, true, nil
	}

	return &orgs[idx], name, false, nil
}
// SelectCreateOrg prompts the user to select an org from at list of orgs
// populated via api request.
//
// The user may select to create a new org, or they may preselect an org
// via a non-empty name parameter.
//
// It returns the object of the selected org (if created a new org was not chosed),
// the name of the selected org, and a boolean indicating if a new org should
// be created.
SelectCreateOrg prompts the user to select an org from at list of orgs
populated via api request.

The user may select to create a new org, or they may preselect an org
via a non-empty name parameter.

It returns the object of the selected org (if created a new org was not chosed),
the name of the selected org, and a boolean indicating if a new org should
be created.
// SelectCreateOrg prompts the user to select an org from at list of orgs // populated via api request . // // The user may select to create a new org or they may preselect an org // via a non - empty name parameter . // // It returns the object of the selected org ( if created a new org was not chosed ) // the name of the selected org and a boolean indicating if a new org should // be created .
func SelectCreateOrg(c context.Context, client *api.Client, name string) (*api.OrgResult, string, bool, error) {
	orgs, err := client.Orgs.List(c)
	if err != nil {
		return nil, "", false, err
	}
	var idx int
	if name == "" {
		idx, name, err = SelectOrgPrompt(orgs)
		if err != nil {
			return nil, "", false, err
		}
	} else {
		found := false
		for i, o := range orgs {
			if o.Body.Name == name {
				found = true
				idx = i
				break
			}
		}
		if !found {
			fmt.Println(promptui.FailedValue("Org name", name))
			return nil, "", false, errs.NewExitError("Org not found")
		}
		fmt.Println(promptui.SuccessfulValue("Org name", name))
	}
	if idx == promptui.SelectedAdd {
		return nil, name, true, nil
	}
	return &orgs[idx], name, false, nil
}
func SelectCreateOrg ( c context . Context , client * api . Client , name string ) ( * api . OrgResult , string , bool , error ) { orgs , err := client . Orgs . List ( c ) if err != nil { return nil , " " , false , err } var idx int if name == " " { idx , name , err = SelectOrgPrompt ( orgs ) if err != nil { return nil , " " , false , err } } else { found := false for i , o := range orgs { if o . Body . Name == name { found = true idx = i break } } if ! found { fmt . Println ( promptui . FailedValue ( " " , name ) ) return nil , " " , false , errs . NewExitError ( " " ) } fmt . Println ( promptui . SuccessfulValue ( " " , name ) ) } if idx == promptui . SelectedAdd { return nil , name , true , nil } return & orgs [ idx ] , name , false , nil }
SelectCreateOrg prompts the user to select an org from at list of orgs
populated via api request.
SelectCreateOrg prompts the user to select an org from at list of orgs populated via api request .
// Get the list of orgs the user has access to