diff --git a/.woodpecker.yml b/.woodpecker.yml index dad4769e323d35f7a2dbb7c30fadb69481458462..72e6341bb53bc67e052700c2a37851c4408fc8ef 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -17,6 +17,9 @@ 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 diff --git a/cmd/spectre/README.md b/cmd/spectre/README.md deleted file mode 100644 index 683bb72fcc02b5a78c23ec89bbc1a84929f1616b..0000000000000000000000000000000000000000 --- a/cmd/spectre/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# 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 diff --git a/cmd/spectre/main.go b/cmd/spectre/main.go index 9248bc2add33ff8eb80061f076f542d7e31ae9f1..d67aac49369826d101f50a521a384cd131a2d7e5 100644 --- a/cmd/spectre/main.go +++ b/cmd/spectre/main.go @@ -11,12 +11,9 @@ ) func main() { fs := flag.NewFlagSet("spectre", flag.ExitOnError) - fs.Usage = func() { - fmt.Fprintln(fs.Output(), "spectre [FLAGS] [site]") - fs.PrintDefaults() - } usernameFlag := fs.String("username", "", "username") secretFlag := fs.String("secret", "", "secret") + siteFlag := fs.String("site", "", "site") counterFlag := fs.Int("counter", 1, "counter") scoperFlag := fs.String("scoper", "com.lyndir.masterpassword", "scoper base") scopeFlag := spectre.Authentication @@ -41,7 +38,7 @@ if templateFlag == "" { templateFlag = scopeFlag.DefaultTemplate() } - if *usernameFlag == "" || *secretFlag == "" || len(os.Args) < 2 { + if *usernameFlag == "" || *secretFlag == "" || *siteFlag == "" { panic("username, secret, and site are required") } @@ -52,7 +49,7 @@ if err != nil { panic(err) } - pw := s.Site(os.Args[1], + pw := s.Site(*siteFlag, spectre.WithScope(scopeFlag), spectre.WithTemplate(templateFlag), spectre.WithCounter(*counterFlag), diff --git a/spectre_test.go b/spectre_test.go index 3bfcec87a7e5a6ba0c54468fd809c78d323e3e51..a794aed52170fba297d73f58b2cca9e5f47993b5 100644 --- a/spectre_test.go +++ b/spectre_test.go @@ -3,7 +3,6 @@ import ( _ "embed" "encoding/xml" - "fmt" "strconv" "testing" @@ -54,34 +53,18 @@ } } // From the website sanity check -func Example() { +func TestSanity(t *testing.T) { s, err := spectre.New("Robert Lee Mitchell", "banana colored duckling") if err != nil { - panic(err) + t.Logf("failed sanity check: %v", err) + t.FailNow() } pw := s.Site("masterpasswordapp.com") - fmt.Println(pw) - // Output: Jejr5[RepuSosp -} - -// Example with options -func Example_second() { - scoper := spectre.SimpleScoper{ - Key: "com.jojodev.jolheiser", - } - s, err := spectre.New("Robert Lee Mitchell", "banana colored duckling", spectre.WithScoper(scoper)) - if err != nil { - panic(err) + if pw != "Jejr5[RepuSosp" { + t.Log("failed sanity check") + t.FailNow() } - - 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