Documentation ¶
Index ¶
- func AskForName[TEntity any](existingNames []string, defaultName string, desc *EntityDescriptor[TEntity]) (name string, err error)
- func AskUserIsCreatingNew[TEntity any](desc *EntityDescriptor[TEntity]) (bool, error)
- func ConfirmDeletion[TEntity any](entity *TEntity, desc *EntityDescriptor[TEntity]) (confirmed bool, err error)
- func CreateUniqueNameValidator(existingNames []string) survey.Validator
- func GetEntityByDisplayName[TEntity any](entityName string, entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
- func GetEntityById[TEntity any](entityId string, entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
- func GetNames[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity]) []string
- func InfoCreation[TEntity any](entity *TEntity, desc *EntityDescriptor[TEntity])
- func InfoDeletion[TEntity any](entity *TEntity, desc *EntityDescriptor[TEntity])
- func PrintList[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity])
- func SelectEntitiesByNamesOrAsk[TEntity any](names []string, entities []TEntity, desc *EntityDescriptor[TEntity]) ([]TEntity, error)
- func SelectEntity[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
- func SelectEntityByNameOrAsk[TEntity any](name string, entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
- func SelectEntityOrCreateOne[TEntity any](entities []TEntity, createEntity func() (*TEntity, error), askForNewFirst bool, ...) (entity *TEntity, wasCreated bool, err error)
- type EntityDescriptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskForName ¶ added in v0.0.21
func AskUserIsCreatingNew ¶
func AskUserIsCreatingNew[TEntity any](desc *EntityDescriptor[TEntity]) (bool, error)
func ConfirmDeletion ¶
func ConfirmDeletion[TEntity any](entity *TEntity, desc *EntityDescriptor[TEntity]) (confirmed bool, err error)
func CreateUniqueNameValidator ¶
func CreateUniqueNameValidator(existingNames []string) survey.Validator
func GetEntityByDisplayName ¶ added in v0.0.34
func GetEntityByDisplayName[TEntity any](entityName string, entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
func GetEntityById ¶
func GetEntityById[TEntity any](entityId string, entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
func GetNames ¶ added in v0.0.21
func GetNames[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity]) []string
func InfoCreation ¶
func InfoCreation[TEntity any](entity *TEntity, desc *EntityDescriptor[TEntity])
func InfoDeletion ¶
func InfoDeletion[TEntity any](entity *TEntity, desc *EntityDescriptor[TEntity])
func PrintList ¶
func PrintList[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity])
func SelectEntitiesByNamesOrAsk ¶ added in v0.0.41
func SelectEntitiesByNamesOrAsk[TEntity any](names []string, entities []TEntity, desc *EntityDescriptor[TEntity]) ([]TEntity, error)
func SelectEntity ¶
func SelectEntity[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
func SelectEntityByNameOrAsk ¶ added in v0.0.41
func SelectEntityByNameOrAsk[TEntity any](name string, entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
func SelectEntityOrCreateOne ¶
Types ¶
type EntityDescriptor ¶
type EntityDescriptor[TEntity any] struct { Name string PluralName string GetDisplayName func(e *TEntity) string GetID func(e *TEntity) string }
EntityDescriptor describes an entity and provides a standardized way to handle generic inputs and messaging related to the entity.
func NewEntityDescriptor ¶
func NewEntityDescriptor[TEntity any]( name, pluralName string, getDisplayName func(*TEntity) string, getId func(*TEntity) string, ) *EntityDescriptor[TEntity]
Click to show internal directories.
Click to hide internal directories.