mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 08:37:20 -04:00
Implement clipboard clearing functionality on Wayland
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"github.com/rwinkhart/MUTN/src/cli"
|
||||
"github.com/rwinkhart/MUTN/src/offline"
|
||||
"os"
|
||||
@@ -9,28 +10,28 @@ import (
|
||||
|
||||
func main() {
|
||||
|
||||
args := os.Args[1:]
|
||||
args := os.Args
|
||||
argsCount := len(args)
|
||||
|
||||
// if no arguments are supplied...
|
||||
if argsCount == 0 {
|
||||
if argsCount == 1 {
|
||||
// list all entries
|
||||
cli.EntryListGen()
|
||||
} else {
|
||||
|
||||
// if the first argument is an entry...
|
||||
if strings.HasPrefix(args[0], "/") {
|
||||
if strings.HasPrefix(args[1], "/") {
|
||||
|
||||
// store location of target entry
|
||||
targetLocation := offline.EntryRoot + offline.PathSeparator + args[0][1:]
|
||||
targetLocation := offline.EntryRoot + offline.PathSeparator + args[1][1:]
|
||||
|
||||
// entry reader shortcut (if no other arguments are supplied)
|
||||
if argsCount == 1 {
|
||||
if argsCount == 2 {
|
||||
cli.EntryReaderShortcut(targetLocation, true)
|
||||
// perform other operations on the entry (if other arguments are supplied)
|
||||
} else if argsCount == 2 {
|
||||
} else if argsCount == 3 {
|
||||
|
||||
switch args[1] {
|
||||
switch args[2] {
|
||||
case "show", "-s":
|
||||
cli.EntryReaderShortcut(targetLocation, false)
|
||||
case "shear": // TODO offline.Shear(targetLocation), exit after run
|
||||
@@ -45,14 +46,14 @@ func main() {
|
||||
cli.HelpMain()
|
||||
}
|
||||
|
||||
} else if argsCount == 3 {
|
||||
} else if argsCount == 4 {
|
||||
|
||||
// declare entry field to perform target operation on
|
||||
|
||||
switch args[1] {
|
||||
switch args[2] {
|
||||
case "copy":
|
||||
var field uint8
|
||||
switch args[2] {
|
||||
switch args[3] {
|
||||
case "password", "-p":
|
||||
field = 0
|
||||
case "username", "-u":
|
||||
@@ -64,11 +65,11 @@ func main() {
|
||||
default:
|
||||
cli.HelpCopy()
|
||||
}
|
||||
offline.CopyField(targetLocation, field)
|
||||
offline.CopyField(targetLocation, field, args[0])
|
||||
case "edit":
|
||||
var field rune
|
||||
field = field // TODO temporary to avoid unused variable error
|
||||
switch args[2] {
|
||||
switch args[3] {
|
||||
case "password", "-p":
|
||||
field = 'p'
|
||||
case "username", "-u":
|
||||
@@ -85,7 +86,7 @@ func main() {
|
||||
case "add":
|
||||
var field rune
|
||||
field = field // TODO temporary to avoid unused variable error
|
||||
switch args[2] {
|
||||
switch args[3] {
|
||||
case "password", "-p":
|
||||
field = 'p'
|
||||
case "note", "-n":
|
||||
@@ -98,7 +99,7 @@ func main() {
|
||||
case "gen":
|
||||
var field rune
|
||||
field = field // TODO temporary to avoid unused variable error
|
||||
switch args[2] {
|
||||
switch args[3] {
|
||||
case "update", "-u": // TODO offline.GenUpdate(targetLocation), exit after run
|
||||
default:
|
||||
cli.HelpGen()
|
||||
@@ -110,11 +111,19 @@ func main() {
|
||||
|
||||
// if the first argument is not an entry...
|
||||
} else {
|
||||
switch args[0] {
|
||||
switch args[1] {
|
||||
case "clipclear":
|
||||
// read previous clipboard contents from stdin
|
||||
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 "init": // TODO offline.Init(), exit after run
|
||||
case "tweak": // TODO offline.Tweak(), exit after run
|
||||
|
||||
case "add":
|
||||
cli.HelpAdd()
|
||||
case "edit":
|
||||
|
||||
Reference in New Issue
Block a user