github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/prompts/library/new.go (about)

     1  package libraryPrompts
     2  
     3  import (
     4  	structureSpec "github.com/taubyte/go-specs/structure"
     5  	libraryLib "github.com/taubyte/tau-cli/lib/library"
     6  	"github.com/taubyte/tau-cli/prompts"
     7  	loginPrompts "github.com/taubyte/tau-cli/prompts/login"
     8  	"github.com/urfave/cli/v2"
     9  )
    10  
    11  func New(ctx *cli.Context) (interface{}, *structureSpec.Library, error) {
    12  	library := &structureSpec.Library{}
    13  
    14  	taken, err := libraryLib.List()
    15  	if err != nil {
    16  		return nil, nil, err
    17  	}
    18  
    19  	library.Name = prompts.GetOrRequireAUniqueName(ctx, NamePrompt, taken)
    20  	library.Description = prompts.GetOrAskForADescription(ctx)
    21  	library.Tags = prompts.GetOrAskForTags(ctx)
    22  
    23  	library.Provider, err = loginPrompts.SelectAProvider(ctx)
    24  	if err != nil {
    25  		return nil, nil, err
    26  	}
    27  
    28  	info, err := RepositoryInfo(ctx, library, true)
    29  	if err != nil {
    30  		return nil, nil, err
    31  	}
    32  
    33  	library.Path = prompts.GetOrRequireAPath(ctx, "Path:")
    34  
    35  	library.Branch = prompts.GetOrRequireABranch(ctx)
    36  
    37  	return info, library, nil
    38  }