Skip to content

Commit

Permalink
show error on linux if clipboard utilities are not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
gottenheim committed Jul 22, 2023
1 parent 550a4e2 commit e249f0f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions details/interactor/cmd_line_interactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ func (i *CommandLineInteractor) waitForUserToComeUpWithAnswer(crd *card.Card) er
}

if ch == 'c' || ch == 'C' {
i.copyFullCardPathToClipboard(crd)
err = i.copyFullCardPathToClipboard(crd)
if err != nil {
return err
}
} else if key == 13 || ch == 's' || ch == 'S' {
return nil
} else if key == 3 || key == 27 {
Expand All @@ -108,9 +111,13 @@ func (i *CommandLineInteractor) waitForUserToComeUpWithAnswer(crd *card.Card) er
}
}

func (i *CommandLineInteractor) copyFullCardPathToClipboard(crd *card.Card) {
clipboard.WriteAll(fmt.Sprintf("%s/%s", crd.Section(), crd.Entry()))
func (i *CommandLineInteractor) copyFullCardPathToClipboard(crd *card.Card) error {
err := clipboard.WriteAll(fmt.Sprintf("%s/%s", crd.Section(), crd.Entry()))
if err != nil {
return err
}
fmt.Println("Card path has been copied to clipboard")
return nil
}

func (i *CommandLineInteractor) askUserHowGoodWasHisAnswer(crd *card.Card, states []*study.CardState) (*study.CardState, error) {
Expand Down

0 comments on commit e249f0f

Please sign in to comment.