func SelectCreateProject(c context.Context, client *api.Client, orgID *identity.ID, name string) (*api.ProjectResult, string, bool, error) {
	var projects []api.ProjectResult
	var err error
	if orgID != nil {
		// Get the list of projects the user has access to in the specified org
		projects, err = listProjects(&c, client, orgID, nil)
		if err != nil {
			return nil, "", false, err
		}
	}

	var idx int
	if name == "" {
		idx, name, err = SelectProjectPrompt(projects)
		if err != nil {
			return nil, "", false, err
		}
	} else {
		found := false
		for i, p := range projects {
			if p.Body.Name == name {
				found = true
				idx = i
				break
			}
		}
		if !found {
			fmt.Println(promptui.FailedValue("Project name", name))
			return nil, "", false, errs.NewExitError("Project not found.")
		}
		fmt.Println(promptui.SuccessfulValue("Project name", name))
	}

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

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

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

It returns the object of the selected project (if created a new project was not chosed),
the name of the selected project, and a boolean indicating if a new project should
be created.
// SelectCreateProject prompts the user to select a project from at list of projects // populated via api request . // // The user may select to create a new project or they may preselect an project // via a non - empty name parameter . // // It returns the object of the selected project ( if created a new project was not chosed ) // the name of the selected project and a boolean indicating if a new project should // be created .
func SelectCreateProject(c context.Context, client *api.Client, orgID *identity.ID, name string) (*api.ProjectResult, string, bool, error) {
	var projects []api.ProjectResult
	var err error
	if orgID != nil {
		projects, err = listProjects(&c, client, orgID, nil)
		if err != nil {
			return nil, "", false, err
		}
	}
	var idx int
	if name == "" {
		idx, name, err = SelectProjectPrompt(projects)
		if err != nil {
			return nil, "", false, err
		}
	} else {
		found := false
		for i, p := range projects {
			if p.Body.Name == name {
				found = true
				idx = i
				break
			}
		}
		if !found {
			fmt.Println(promptui.FailedValue("Project name", name))
			return nil, "", false, errs.NewExitError("Project not found.")
		}
		fmt.Println(promptui.SuccessfulValue("Project name", name))
	}
	if idx == promptui.SelectedAdd {
		return nil, name, true, nil
	}
	return &projects[idx], name, false, nil
}
func SelectCreateProject ( c context . Context , client * api . Client , orgID * identity . ID , name string ) ( * api . ProjectResult , string , bool , error ) { var projects [ ] api . ProjectResult var err error if orgID != nil { projects , err = listProjects ( & c , client , orgID , nil ) if err != nil { return nil , " " , false , err } } var idx int if name == " " { idx , name , err = SelectProjectPrompt ( projects ) if err != nil { return nil , " " , false , err } } else { found := false for i , p := range projects { if p . 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 & projects [ idx ] , name , false , nil }
SelectCreateProject prompts the user to select a project from at list of projects
populated via api request.
SelectCreateProject prompts the user to select a project from at list of projects populated via api request .
// Get the list of projects the user has access to in the specified org