mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Move "clipclear" argument functionality to offline function to better facilitate third-party implementations
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"github.com/rwinkhart/MUTN/src/cli"
|
"github.com/rwinkhart/MUTN/src/cli"
|
||||||
"github.com/rwinkhart/MUTN/src/offline"
|
"github.com/rwinkhart/MUTN/src/offline"
|
||||||
"os"
|
"os"
|
||||||
@@ -113,14 +112,7 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
switch args[1] {
|
switch args[1] {
|
||||||
case "clipclear":
|
case "clipclear":
|
||||||
// read previous clipboard contents from stdin
|
offline.ClipClearArgument()
|
||||||
clipScanner := bufio.NewScanner(os.Stdin)
|
|
||||||
if clipScanner.Scan() {
|
|
||||||
oldContents := clipScanner.Text()
|
|
||||||
offline.ClipClear(oldContents)
|
|
||||||
} else {
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
case "sync": // TODO online.Sync(), exit after run
|
case "sync": // TODO online.Sync(), exit after run
|
||||||
case "init": // TODO offline.Init(), exit after run
|
case "init": // TODO offline.Init(), exit after run
|
||||||
case "tweak": // TODO offline.Tweak(), exit after run
|
case "tweak": // TODO offline.Tweak(), exit after run
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package offline
|
package offline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@@ -34,3 +35,14 @@ func writeToStdin(cmd *exec.Cmd, input string) {
|
|||||||
io.WriteString(stdin, input)
|
io.WriteString(stdin, input)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ClipClearArgument() {
|
||||||
|
// read previous clipboard contents from stdin
|
||||||
|
clipScanner := bufio.NewScanner(os.Stdin)
|
||||||
|
if clipScanner.Scan() {
|
||||||
|
oldContents := clipScanner.Text()
|
||||||
|
ClipClear(oldContents)
|
||||||
|
} else {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user