github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/cli/commands/resources/repository/helpers.go (about)

     1  package repositoryCommands
     2  
     3  import (
     4  	"github.com/taubyte/tau-cli/i18n"
     5  	projectLib "github.com/taubyte/tau-cli/lib/project"
     6  	repositoryLib "github.com/taubyte/tau-cli/lib/repository"
     7  	"github.com/taubyte/tau-cli/singletons/config"
     8  	"github.com/urfave/cli/v2"
     9  )
    10  
    11  func (lib *repositoryCommands) selectResource(ctx *cli.Context) (project config.Project, resource Resource, info *repositoryLib.Info, err error) {
    12  	project, err = projectLib.SelectedProjectConfig()
    13  	if err != nil {
    14  		return
    15  	}
    16  
    17  	// Confirm project is cloned
    18  	_, err = project.Interface()
    19  	if err != nil {
    20  		i18n.Help().BeSureToCloneProject()
    21  		return
    22  	}
    23  
    24  	resource, err = lib.PromptsGetOrSelect(ctx)
    25  	if err != nil {
    26  		return
    27  	}
    28  
    29  	info = &repositoryLib.Info{
    30  		FullName: resource.Get().RepoName(),
    31  		ID:       resource.Get().RepoID(),
    32  		Type:     lib.Type,
    33  		DoClone:  true,
    34  	}
    35  
    36  	return
    37  }