Documentation ¶
Index ¶
- func AskForName[TEntity any](existingNames []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 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 SelectEntity[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
- func SelectEntityOrCreateOne[TEntity any](entities []TEntity, createEntity func() (*TEntity, error), askForNewFirst bool, ...) (*TEntity, error)
- type EntityDescriptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskForName ¶ added in v0.0.21
func AskForName[TEntity any](existingNames []string, desc *EntityDescriptor[TEntity]) (name string, err error)
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 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 SelectEntity ¶
func SelectEntity[TEntity any](entities []TEntity, desc *EntityDescriptor[TEntity]) (*TEntity, error)
func SelectEntityOrCreateOne ¶
func SelectEntityOrCreateOne[TEntity any]( entities []TEntity, createEntity func() (*TEntity, error), askForNewFirst bool, desc *EntityDescriptor[TEntity], ) (*TEntity, error)
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.