Documentation ¶
Index ¶
- type AlbumFormSession
- type BackupSuggestionPort
- type CreateAlbumPort
- type DeleteAlbumPort
- type DeleteSession
- type EditDateSession
- type ExistingRecord
- type ExistingRecordRepositoryPort
- type FormFmtAdapter
- type FormUseCase
- type InteractiveActionsPort
- type InteractiveRendererPort
- type InteractiveSession
- func (i *InteractiveSession) BackupAll()
- func (i *InteractiveSession) BackupSelected()
- func (i *InteractiveSession) CreateFromSelectedSuggestion(owner string)
- func (i *InteractiveSession) CreateNew(owner string)
- func (i *InteractiveSession) DeleteSelectedAlbum()
- func (i *InteractiveSession) EditSelectedAlbumDates()
- func (i *InteractiveSession) EditSelectedAlbumName()
- func (i *InteractiveSession) HasError() bool
- func (i *InteractiveSession) MoveDown()
- func (i *InteractiveSession) MoveUp()
- func (i *InteractiveSession) NextPage()
- func (i *InteractiveSession) PreviousPage()
- func (i *InteractiveSession) Refresh()
- func (i *InteractiveSession) Start() error
- type InteractiveViewState
- type NoopRepository
- type Period
- type PrintReadTerminalPort
- type Record
- type RecordCreation
- type RecordsState
- type RenameAlbumPort
- type RenameSession
- type StaticSession
- type SuggestionRecord
- type SuggestionRecordRepositoryPort
- type UpdateAlbumPort
- type UserInputPort
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlbumFormSession ¶
type AlbumFormSession struct {
// contains filtered or unexported fields
}
func NewCreateAlbumForm ¶
func NewCreateAlbumForm(actionsPort CreateAlbumPort, terminalPort PrintReadTerminalPort) *AlbumFormSession
type BackupSuggestionPort ¶
type BackupSuggestionPort interface {
BackupSuggestion(record *SuggestionRecord, existing *ExistingRecord, listener InteractiveRendererPort) error
}
type CreateAlbumPort ¶
type CreateAlbumPort interface {
Create(createRequest RecordCreation) error
}
type DeleteAlbumPort ¶
type DeleteSession ¶
type DeleteSession struct {
// contains filtered or unexported fields
}
func NewDeleteAlbumForm ¶
func NewDeleteAlbumForm(actionPort DeleteAlbumPort, terminalPort PrintReadTerminalPort) *DeleteSession
func (*DeleteSession) DeleteAlbum ¶
func (s *DeleteSession) DeleteAlbum(record Record) (bool, error)
type EditDateSession ¶
type EditDateSession struct {
// contains filtered or unexported fields
}
func NewEditAlbumDateForm ¶
func NewEditAlbumDateForm(actionPort UpdateAlbumPort, terminalPort PrintReadTerminalPort) *EditDateSession
func (*EditDateSession) EditAlbumDates ¶
func (s *EditDateSession) EditAlbumDates(record Record) error
type ExistingRecord ¶
type ExistingRecord struct { FolderName string // FolderName is a suggested name when Suggestion is true, not a unique key Name string Start, End time.Time Count int ActivePeriods []Period }
ExistingRecord is an album already existing
type ExistingRecordRepositoryPort ¶
type ExistingRecordRepositoryPort interface {
FindExistingRecords() ([]*ExistingRecord, error)
}
ExistingRecordRepositoryPort is the port providing data to the UI
type FormFmtAdapter ¶
type FormFmtAdapter struct{}
FormFmtAdapter is a simple adapter to use fmt package to print and read to standard outputs
func (FormFmtAdapter) Print ¶
func (f FormFmtAdapter) Print(question string)
func (FormFmtAdapter) ReadAnswer ¶
func (f FormFmtAdapter) ReadAnswer() (string, error)
type FormUseCase ¶
type FormUseCase struct {
TerminalPort PrintReadTerminalPort
}
func NewSimpleForm ¶
func NewSimpleForm() *FormUseCase
NewSimpleForm creates a simple form using standard output and input
func (*FormUseCase) ReadBool ¶
func (f *FormUseCase) ReadBool(label string, notation string) (bool, bool)
ReadBool reads a boolean, notation can be Y/n if (_, false) is interpreted as positive
func (*FormUseCase) ReadDate ¶
ReadDate reads a date from standard input, return true if reading was a success.
func (*FormUseCase) ReadString ¶
func (f *FormUseCase) ReadString(label string, defaultValue string) (string, bool)
ReadString read a string from the standard input
type InteractiveActionsPort ¶
type InteractiveActionsPort interface { CreateAlbumPort RenameAlbumPort UpdateAlbumPort DeleteAlbumPort BackupSuggestionPort }
InteractiveActionsPort are actions on 'SuggestionRecord.Suggestion = false' records
type InteractiveRendererPort ¶
type InteractiveRendererPort interface { PrintReadTerminalPort Render(state *InteractiveViewState) error Height() int // TakeOverScreen is clearing the screen and let another object handling the rendering TakeOverScreen() }
InteractiveRendererPort is handling the rendering of an interactive session
type InteractiveSession ¶
type InteractiveSession struct {
// contains filtered or unexported fields
}
func NewInteractiveSession ¶
func NewInteractiveSession(actions InteractiveActionsPort, existingRepository ExistingRecordRepositoryPort, suggestionRepository SuggestionRecordRepositoryPort, owner string) *InteractiveSession
func (*InteractiveSession) BackupAll ¶ added in v1.5.0
func (i *InteractiveSession) BackupAll()
func (*InteractiveSession) BackupSelected ¶
func (i *InteractiveSession) BackupSelected()
func (*InteractiveSession) CreateFromSelectedSuggestion ¶
func (i *InteractiveSession) CreateFromSelectedSuggestion(owner string)
func (*InteractiveSession) CreateNew ¶
func (i *InteractiveSession) CreateNew(owner string)
func (*InteractiveSession) DeleteSelectedAlbum ¶
func (i *InteractiveSession) DeleteSelectedAlbum()
func (*InteractiveSession) EditSelectedAlbumDates ¶
func (i *InteractiveSession) EditSelectedAlbumDates()
func (*InteractiveSession) EditSelectedAlbumName ¶
func (i *InteractiveSession) EditSelectedAlbumName()
func (*InteractiveSession) HasError ¶
func (i *InteractiveSession) HasError() bool
func (*InteractiveSession) MoveDown ¶
func (i *InteractiveSession) MoveDown()
func (*InteractiveSession) MoveUp ¶
func (i *InteractiveSession) MoveUp()
func (*InteractiveSession) NextPage ¶
func (i *InteractiveSession) NextPage()
func (*InteractiveSession) PreviousPage ¶
func (i *InteractiveSession) PreviousPage()
func (*InteractiveSession) Refresh ¶
func (i *InteractiveSession) Refresh()
Refresh updates the screen
func (*InteractiveSession) Start ¶
func (i *InteractiveSession) Start() error
type InteractiveViewState ¶
type InteractiveViewState struct { RecordsState Actions []string }
type NoopRepository ¶
type NoopRepository struct{}
NoopRepository is only used for Noop version
func (NoopRepository) Count ¶
func (r NoopRepository) Count() int
func (NoopRepository) FindSuggestionRecords ¶
func (r NoopRepository) FindSuggestionRecords() []*SuggestionRecord
func (NoopRepository) Rejects ¶
func (r NoopRepository) Rejects() int
type PrintReadTerminalPort ¶
PrintReadTerminalPort is a port to print questions (simple strings), and read answers (strings as well)
type Record ¶
type Record struct { Indent int // Indent is to represent the list as a tree Suggestion bool // Suggestion is TRUE when it's a suggestion, not an existing album. FolderName string // FolderName is a suggested name when Suggestion is true, not a unique key Name string Start, End time.Time Count int // Count is the number of files relevant to the context (if in a tree branch) TotalCount int // TotalCount is the total number of file ParentExistingRecord *ExistingRecord // ParentExistingRecord is the album if the suggestion is a child (used to limit the backup to a single album) SuggestionRecord *SuggestionRecord // SuggestionRecord is the original when Suggestion is true (used for backup) }
type RecordCreation ¶
type RecordCreation struct { Owner string FolderName string // FolderName might be empty to be generated Name string Start, End time.Time }
RecordCreation contains parameter to create a new album.
type RecordsState ¶
type RecordsState struct { Records []*Record Rejected int // Rejected is the number of file that has been rejected (ignored) Selected int // Selected can be -1 to not highlight any line PageSize int // PageSize can be 0 to disable pagination FirstElement int // FirstElement is the index of the first shown record ; default (or pagination disabled): 0 }
type RenameAlbumPort ¶
type RenameSession ¶
type RenameSession struct {
// contains filtered or unexported fields
}
func NewRenameAlbumForm ¶
func NewRenameAlbumForm(actionPort RenameAlbumPort, terminalPort PrintReadTerminalPort) *RenameSession
func (*RenameSession) EditAlbumName ¶
func (s *RenameSession) EditAlbumName(record Record) error
type StaticSession ¶
type StaticSession struct {
// contains filtered or unexported fields
}
func NewSimpleSession ¶
func NewSimpleSession(existingRepository ExistingRecordRepositoryPort, suggestionRepository SuggestionRecordRepositoryPort) *StaticSession
func (*StaticSession) Render ¶
func (s *StaticSession) Render() error
type SuggestionRecord ¶
type SuggestionRecord struct { FolderName string // FolderName is a suggested name when Suggestion is true, not a unique key Name string Start, End time.Time Distribution map[string]int // Distribution is the number of media found for each day (format YYYY-MM-DD) Original interface{} // Original is used by adapter for targeted backup }
SuggestionRecord is a record that will be displayed and handled in the UI. It can be an existing catalog.Album or a backup.FoundAlbum
type SuggestionRecordRepositoryPort ¶
type SuggestionRecordRepositoryPort interface { FindSuggestionRecords() []*SuggestionRecord Count() int Rejects() int }
SuggestionRecordRepositoryPort is the port providing data to the UI
func NewNoopRepository ¶
func NewNoopRepository() SuggestionRecordRepositoryPort
NewNoopRepository implements both SuggestionRecordRepositoryPort and ExistingRecordRepositoryPort but won't returns anything.
type UpdateAlbumPort ¶
type UserInputPort ¶
type UserInputPort interface {
StartListening()
}
UserInputPort listens user input (keyboard) to interact with the session