Rename to passgo and run go fmt.

This commit is contained in:
Greg 2019-09-05 06:41:39 -04:00
parent fc7a4c272e
commit 28ccd6d107
8 changed files with 135 additions and 138 deletions

4
.gitignore vendored
View File

@ -1,2 +1,2 @@
cmd/gpass/gpass
cmd/gpass-gui/gpass-gui
cmd/gpass/passgo
cmd/gpass-gui/passgo-gui

View File

@ -1,4 +1,4 @@
# gpass
# passgo
This repository includes Go code to interact with pass, the Unix password
manager. Library code is provided to open a password store, list
@ -7,7 +7,7 @@ a simple passphrase input function, or, if gpg-agent is running (on MacOS),
it will connect automatically to request your GPG passphrase.
```go
store, err := gpass.GetStore()
store, err := passgo.GetStore()
if err != nil { ... }
passlist := store.List()
//storeDir := store.Dir
@ -15,7 +15,7 @@ for _,x := range passlist {
if x.Pathname = "myPass" {
p, err := store.Decrypt(x.Pathname)
if err == nil {
gpass.Clip(p) // put on the clipboard
passgo.Clip(p) // put on the clipboard
} else {
log.Fatal("Cannot decrypt ", x.Pathname)
}

View File

@ -1,28 +0,0 @@
package main
import (
golog "log"
"os"
)
type logLevelT int
const (
Fatal logLevelT = 1 << iota
Error
Warn
Info
Debug
DebugGfx
)
var loglevel = Fatal | Error | Warn | Info
func log(level logLevelT, msg ...interface{}) {
if level & loglevel != 0 {
golog.Print(msg...)
}
if level & Fatal != 0 {
os.Exit(-1)
}
}

28
cmd/passgo-gui/log.go Normal file
View File

@ -0,0 +1,28 @@
package main
import (
golog "log"
"os"
)
type logLevelT int
const (
Fatal logLevelT = 1 << iota
Error
Warn
Info
Debug
DebugGfx
)
var loglevel = Fatal | Error | Warn | Info
func log(level logLevelT, msg ...interface{}) {
if level&loglevel != 0 {
golog.Print(msg...)
}
if level&Fatal != 0 {
os.Exit(-1)
}
}

View File

@ -4,35 +4,34 @@ package main
import (
//"fmt"
"path"
"strings"
"image"
"image/color"
"path"
"strings"
"sync"
"gioui.org/ui"
"gioui.org/ui/app"
"gioui.org/ui/f32"
"gioui.org/ui/gesture"
"gioui.org/ui/input"
"gioui.org/ui/key"
"gioui.org/ui/layout"
"gioui.org/ui/text"
"gioui.org/ui/measure"
"gioui.org/ui/f32"
"gioui.org/ui/paint"
"gioui.org/ui/gesture"
"gioui.org/ui/pointer"
"gioui.org/ui/text"
"github.com/fsnotify/fsnotify"
"golang.org/x/image/font/gofont/goregular"
"golang.org/x/image/font/sfnt"
"git.wow.st/gmp/gpass"
"git.wow.st/gmp/passgo"
)
func main() {
var err error
store,err = gpass.GetStore()
store, err = passgo.GetStore()
if err != nil {
log(Fatal, err)
}
@ -45,9 +44,9 @@ func main() {
}
var (
l []gpass.Pass
l []passgo.Pass
mux sync.Mutex
store *gpass.Store
store *passgo.Store
updated chan struct{}
)
@ -114,7 +113,6 @@ func rrect(ops *ui.Ops, width, height, se, sw, nw, ne float32) {
b.End()
}
func (b *Button) Layout(c ui.Config, ops *ui.Ops, q input.Queue, cs layout.Constraints) layout.Dimensions {
b.clicked = false
for ev, ok := b.Click.Next(q); ok; ev, ok = b.Click.Next(q) {
@ -178,7 +176,9 @@ func eventLoop() {
_, n := path.Split(x.Pathname)
s := strings.Repeat(" /", x.Level)
z := ""
if x.Dir { z = "/" }
if x.Dir {
z = "/"
}
passBtns = append(passBtns, &Button{
Face: face,
Label: strings.Join([]string{s, n, z}, ""),
@ -190,7 +190,6 @@ func eventLoop() {
}
updateBtns()
for {
select {
case <-updated:
@ -224,7 +223,7 @@ func eventLoop() {
//p,err := store.Decrypt(name, prompt)
p, err := store.Decrypt(name)
if err == nil {
gpass.Clip(p)
passgo.Clip(p)
} else {
log(Info, "Can't decrypt ", name)
log(Info, err)
@ -240,4 +239,3 @@ func eventLoop() {
}
}
}

View File

@ -6,11 +6,11 @@ import (
"path"
"strings"
"git.wow.st/gmp/gpass"
"git.wow.st/gmp/passgo"
)
func usage() {
fmt.Println("gpass [-c|--clip] [name]")
fmt.Println("passgo [-c|--clip] [name]")
os.Exit(-1)
}
@ -35,7 +35,7 @@ func parse(args []string) ([]string,options) {
}
func main() {
store,err := gpass.GetStore()
store, err := passgo.GetStore()
if err != nil {
fmt.Println(err)
os.Exit(-1)
@ -54,7 +54,9 @@ func main() {
_, n := path.Split(x.Pathname)
s := strings.Repeat(" /", x.Level)
z := ""
if x.Dir { z = "/" }
if x.Dir {
z = "/"
}
fmt.Println(strings.Join([]string{s, n, z}, ""))
}
case 1:
@ -64,7 +66,7 @@ func main() {
os.Exit(-1)
}
if opts.clip {
gpass.Clip(p)
passgo.Clip(p)
} else {
fmt.Print(p)
}
@ -72,4 +74,3 @@ func main() {
usage()
}
}

View File

@ -1,11 +1,11 @@
//+build !android !linux
package gpass
package passgo
import (
"fmt"
"bufio"
"bytes"
"fmt"
"os"
"os/exec"
"os/user"
@ -90,4 +90,3 @@ func Clip(x string) {
cmd.Stdin = b
cmd.Run()
}

View File

@ -1,4 +1,4 @@
package gpass
package passgo
import (
"bufio"
@ -212,4 +212,3 @@ func (s *Store) Decrypt(name string, prompts ...func() []byte) (string,error) {
}
return string(ra), nil
}