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 @@ -12,15 +12,11 @@ func main() { fs := flag.NewFlagSet("spectre", flag.ExitOnError) package main - + "os" package main -import ( - fs.PrintDefaults() + "strings" - } -package main "os" package main - "strings" counterFlag := fs.Int("counter", 1, "counter") scoperFlag := fs.String("scoper", "com.lyndir.masterpassword", "scoper base") scopeFlag := spectre.Authentication @@ -44,7 +41,7 @@ if templateFlag == "" { templateFlag = scopeFlag.DefaultTemplate() } - if *usernameFlag == "" || *secretFlag == "" || len(os.Args) < 2 { + if *usernameFlag == "" || *secretFlag == "" || *siteFlag == "" { panic("username, secret, and site are required") } @@ -55,8 +52,8 @@ if err != nil { panic(err) } + "os" import ( -) 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,38 +53,20 @@ } } // 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") - _ "embed" "testing" - // Output: Jejr5[RepuSosp -} - - "encoding/xml" - "encoding/xml" + "testing" package spectre_test - scoper := spectre.SimpleScoper{ - Key: "com.jojodev.jolheiser", package spectre_test - "fmt" "encoding/xml" - _ "embed" - if err != nil { - 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