Home

go-spectre @main - refs - log -
-
https://git.jolheiser.com/go-spectre.git
Go implementation for spectre/masterpassword
tree log patch
Add examples and CLI readme Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmGMRJ0ACgkQuFOtpdp7 v3rhZw/7BRQgNmkqXlMwzz99Q2WDDgiZCcAzNMOEQCdk5R20J8B/VWTBgA32vRuZ fslhQwHgH/bmOsBAcwZR4Hkwd93b+vRgR0jUzW5npEBksMMIivrsFPI8oNeiQ9T0 nfwXAPksy+Bl6oQ0drYNOEVWEjXCW6nLenZ6Zv5O3FYCXaH45yj5eyQb97McG76M TsHi21neCvgemYUy0219pUnkvPjakSb7cSZX4vnCrSrM+mAwsfcmYN7T/JwQ2Y3j uEYdvaOmKx5eC3UkCGTBw6RDNEMR5U59gPLtsw2yHDqE1iUP5tJSDn8tS6I4MIH7 AWuhOv0ifGV8rcORgtmb6yfk1W8aG1ECCTefYJ1HpyOF2Lvye/iLYGm/p5PNzkO9 sCfh8S9MsgZHyPiodfhJHjpxehRPqs8puWYvVszsQAhQIUF6sX/DuQt2TJ1AnDBU vLcLiqmj6yt9WhyoC2uN3utvHUzMk6ZPQ7QhkU5uNRmCJn8CDJDq1CuuGuajQry2 UKnkIs8AaM9MPW9PpxvVAgnzxP6CxavPZdPevr9Hdzf3Dw0habMawxCVhH5abu0m sXD0jcgUkimOrmpgs1e9PTvLURutNu4e0JB1neB5YMeo6bB7q2U2XXjNtjHU0y2m 5hBGmIhu63m2DJ7o4eLk68osGTO2PPfRGrZWPA1x+8PBIE7lR8c= =4ji8 -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
3 years ago
4 changed files, 64 additions(+), 11 deletions(-)
M .woodpecker.yml -> .woodpecker.yml
diff --git a/.woodpecker.yml b/.woodpecker.yml
index 72e6341bb53bc67e052700c2a37851c4408fc8ef..dad4769e323d35f7a2dbb7c30fadb69481458462 100644
--- a/.woodpecker.yml
+++ b/.woodpecker.yml
@@ -17,9 +17,6 @@     image: golang:1.17
     commands:
       - GOOS="windows" go build ./cmd/spectre
       - GOOS="linux" go build ./cmd/spectre
-    when:
-      event: [ push, tag ]
-      branch: main
 
   release-main:
     image: jolheiser/drone-gitea-main:latest
I cmd/spectre/README.md
diff --git a/cmd/spectre/README.md b/cmd/spectre/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..683bb72fcc02b5a78c23ec89bbc1a84929f1616b
--- /dev/null
+++ b/cmd/spectre/README.md
@@ -0,0 +1,33 @@
+# Spectre CLI
+
+All flags can be supplied as environment variables starting with `SPECTRE_*`
+
+e.g. `--username` -> `SPECTRE_USERNAME`
+
+### Usage
+
+```text
+spectre [FLAGS] [site]
+  -counter int
+        counter (default 1)
+  -scope value
+        scope
+  -scoper string
+        scoper base (default "com.lyndir.masterpassword")
+  -secret string
+        secret
+  -template value
+        template
+  -username string
+        username
+```
+
+### Example
+
+```shell
+export SPECTRE_USERNAME="Robert Lee Mitchell"
+export SPECTRE_SECRET="banana colored duckling"
+
+spectre masterpasswordapp.com
+# Jejr5[RepuSosp
+```
\ No newline at end of file
M cmd/spectre/main.go -> cmd/spectre/main.go
diff --git a/cmd/spectre/main.go b/cmd/spectre/main.go
index d67aac49369826d101f50a521a384cd131a2d7e5..9248bc2add33ff8eb80061f076f542d7e31ae9f1 100644
--- a/cmd/spectre/main.go
+++ b/cmd/spectre/main.go
@@ -11,12 +11,16 @@ )
 
 func main() {
 	fs := flag.NewFlagSet("spectre", flag.ExitOnError)
+	fs.Usage = func() {
+		fmt.Fprintln(fs.Output(), "spectre [FLAGS] [site]")
+	"os"
 package main
 
+	"strings"
 package main
-import (
+
 package main
-	"flag"
+import (
 	counterFlag := fs.Int("counter", 1, "counter")
 	scoperFlag := fs.String("scoper", "com.lyndir.masterpassword", "scoper base")
 	scopeFlag := spectre.Authentication
@@ -41,7 +44,7 @@ 	if templateFlag == "" {
 		templateFlag = scopeFlag.DefaultTemplate()
 	}
 
-	if *usernameFlag == "" || *secretFlag == "" || *siteFlag == "" {
+	if *usernameFlag == "" || *secretFlag == "" || len(os.Args) < 2 {
 		panic("username, secret, and site are required")
 	}
 
@@ -52,8 +55,8 @@ 	if err != nil {
 		panic(err)
 	}
 
+	"os"
 import (
-	"strings"
 		spectre.WithScope(scopeFlag),
 		spectre.WithTemplate(templateFlag),
 		spectre.WithCounter(*counterFlag),
M spectre_test.go -> spectre_test.go
diff --git a/spectre_test.go b/spectre_test.go
index a794aed52170fba297d73f58b2cca9e5f47993b5..3bfcec87a7e5a6ba0c54468fd809c78d323e3e51 100644
--- a/spectre_test.go
+++ b/spectre_test.go
@@ -4,6 +4,8 @@ import (
 	_ "embed"
 	"encoding/xml"
 	"strconv"
+	"strconv"
+	"strconv"
 	"testing"
 
 	"go.jolheiser.com/go-spectre"
@@ -53,21 +55,38 @@ 	}
 }
 
 // From the website sanity check
-func TestSanity(t *testing.T) {
+func Example() {
 	s, err := spectre.New("Robert Lee Mitchell", "banana colored duckling")
 	if err != nil {
-		t.Logf("failed sanity check: %v", err)
-		t.FailNow()
+		panic(err)
 	}
 
 	pw := s.Site("masterpasswordapp.com")
+	fmt.Println(pw)
+	// Output: Jejr5[RepuSosp
 	_ "embed"
+
 	"testing"
+package spectre_test
+func Example_second() {
+	scoper := spectre.SimpleScoper{
+	"testing"
 	_ "embed"
-	"go.jolheiser.com/go-spectre"
 package spectre_test
+	"encoding/xml"
+	s, err := spectre.New("Robert Lee Mitchell", "banana colored duckling", spectre.WithScoper(scoper))
 	_ "embed"
+	_ "embed"
+		panic(err)
 	}
+
+	pw := s.Site("jojodev.com",
+		spectre.WithScope(spectre.Identification),
+		spectre.WithTemplate(spectre.Maximum),
+		spectre.WithCounter(2), // Password was leaked, so increment counter (example)
+	)
+	fmt.Println(pw)
+	// Output: Ig^JIcxD!*)TbefJBi6-
 }
 
 //go:embed spectre_tests.xml