feat: add restore
command to serve last item
This commit is contained in:
parent
6b604f2ef2
commit
676fea9c99
1 changed files with 16 additions and 0 deletions
16
main.go
16
main.go
|
@ -33,6 +33,8 @@ var (
|
|||
clearTool = clearer.Flag("tool", "Which selector to use: dmenu/rofi/wofi/STDOUT").Short('t').Default("dmenu").String()
|
||||
clearToolArgs = clearer.Flag("tool-args", "Extra arguments to pass to the --tool").Short('T').Default("").String()
|
||||
clearAll = clearer.Flag("all", "Remove all items").Short('a').Default("false").Bool()
|
||||
|
||||
restorer = app.Command("restore", "Serve the last recorded item from history")
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -78,6 +80,20 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
case "restore":
|
||||
_, history, err := getHistory(*histpath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if len(history) == 0 {
|
||||
log.Println("Nothing to restore")
|
||||
return
|
||||
}
|
||||
|
||||
if err := exec.Command("wl-copy", "--", history[len(history)-1]).Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
case "clear":
|
||||
histfile, history, err := getHistory(*histpath)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue