Skip to content

Commit ffd0499

Browse files
committed
refactor: restructure and tidy up
1 parent 62b0ea1 commit ffd0499

17 files changed

+62
-45
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Binaries for programs and plugins
2+
# ---
3+
24
*.exe
35
*.exe~
46
*.dll
@@ -7,8 +9,12 @@
79
shoutrrr
810

911
# Test binary, build with `go test -c`
12+
# ---
13+
1014
*.test
1115

1216
# Output of the go coverage tool, specifically when used with LiteIDE
17+
# ---
18+
1319
*.out
1420
.idea

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Arctic Bit
3+
Copyright (c) 2019 Containrrr
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+46-4
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,60 @@
4242

4343
### Using Shoutrrr
4444

45-
Using shoutrrr is as easy as:
45+
#### As a package
4646

47-
```
47+
Using shoutrrr is easy! There is currently two ways of using it as a package.
48+
49+
##### Using the direct send command
50+
51+
```go
4852
url := "slack://token-a/token-b/token-c"
4953
err := shoutrrr.Send(url, "Hello world (or slack channel) !")
5054

5155
```
5256

53-
If you've provided the environment variable `SHOUTRRR_URL`, you may instead use
57+
##### Using a sender
58+
```go
59+
url := "slack://token-a/token-b/token-c"
60+
sender := shoutrrr.CreateSender(url)
61+
sender.Send("Hello world (or slack channel) !", map[string]string { /* ... */ })
62+
```
63+
64+
#### Through the CLI
65+
66+
Start by running the `build.sh` script.
67+
You may then run the shoutrrr executable:
68+
69+
```shell
70+
$ ./shoutrrr
71+
72+
Usage:
73+
./shoutrrr <ActionVerb> [...]
74+
Possible actions: send, verify, generate
75+
```
76+
77+
##### Action details
5478

79+
```shell
80+
$ ./shoutrrr send
81+
Usage:
82+
./shoutrrr send [OPTIONS] <URL> <Message [...]>
83+
84+
OPTIONS:
85+
-verbose
86+
display additional output
87+
```
88+
89+
```shell
90+
$ ./shoutrrr verify
91+
Usage:
92+
./shoutrrr send [OPTIONS] <URL> <Message [...]>
5593
```
56-
err := shoutrrr.SendEnv("Hello world (or slack channel) !")
94+
95+
```shell
96+
$ ./shoutrrr generate
97+
Usage:
98+
./shoutrrr generate [OPTIONS] <service>
5799
```
58100

59101
### Service URL:s

build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go build -o ./shoutrrr ./cmd/shoutrrr

pkg/cli/generate.go cmd/shoutrrr/generate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func generate() action {
3636
return 1
3737
},
3838
FlagSet: *flag.NewFlagSet("generate", flag.ExitOnError),
39-
Usage: "%s generate [OPTIONS] <service>\n",
39+
Usage: "%s generate [OPTIONS] <service>\n",
4040
}
4141

4242
// action.FlagSet.BoolVar(&verbose, "verbose", false, "display additional output")
File renamed without changes.

pkg/cli/send.go cmd/shoutrrr/send.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
var verbose bool
15+
var usageExample = "%s send [OPTIONS] <URL> <Message [...]>\n"
1516

1617
func send() action {
1718
action := action{
@@ -46,7 +47,7 @@ func send() action {
4647
return 0
4748
},
4849
FlagSet: *flag.NewFlagSet("send", flag.ExitOnError),
49-
Usage: "%s send [OPTIONS] <URL> <Message [...]>\n",
50+
Usage: usageExample,
5051
}
5152

5253
action.FlagSet.BoolVar(&verbose, "verbose", false, "display additional output")

pkg/cli/verify.go cmd/shoutrrr/verify.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ func verify() action {
3434
return 0
3535
},
3636
FlagSet: *flag.NewFlagSet("verify", flag.ExitOnError),
37-
Usage: "%s send [OPTIONS] <URL> <Message [...]>\n",
37+
Usage: "%s send [OPTIONS] <URL> <Message [...]>\n",
3838
}
3939
}

config.yml

-16
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pkg/services/smtp/smtp_failures.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package smtp
22

3-
import "github.com/containrrr/shoutrrr/pkg/failures"
3+
import "github.com/containrrr/shoutrrr/internal/failures"
44

55
const (
66
// FailUnknown is the default FailureID

pkg/services/smtp/smtp_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"testing"
1111
"unsafe"
1212

13-
"github.com/containrrr/shoutrrr/pkg/failures"
14-
"github.com/containrrr/shoutrrr/pkg/testutils"
13+
"github.com/containrrr/shoutrrr/internal/failures"
14+
"github.com/containrrr/shoutrrr/internal/testutils"
1515
"github.com/containrrr/shoutrrr/pkg/util"
1616

1717
. "github.com/onsi/ginkgo"

shoutrrr.go

+1-18
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/containrrr/shoutrrr/pkg/router"
77
"github.com/containrrr/shoutrrr/pkg/types"
8-
"github.com/containrrr/shoutrrr/pkg/util/queue"
98
)
109

1110
var routing = router.ServiceRouter{}
@@ -15,7 +14,7 @@ func SetLogger(logger *log.Logger) {
1514
routing.SetLogger(logger)
1615
}
1716

18-
// Send lets you send shoutrrr notifications using a supplied url and message
17+
// Send notifications using a supplied url and message
1918
func Send(rawURL string, message string) error {
2019
service, err := routing.Locate(rawURL)
2120
if err != nil {
@@ -28,20 +27,4 @@ func Send(rawURL string, message string) error {
2827
// CreateSender returns a notification sender configured according to the supplied URL
2928
func CreateSender(rawURL string) (types.Service, error) {
3029
return routing.Locate(rawURL)
31-
}
32-
33-
// CreateQueue returns a notification queued sender configured according to the supplied URL
34-
func CreateQueue(rawURL string) (types.QueuedSender, error) {
35-
service, err := routing.Locate(rawURL)
36-
if err != nil {
37-
return nil, err
38-
}
39-
40-
return queue.GetQueued(service), nil
41-
}
42-
43-
// VerifyURL lets you verify that a configuration URL is valid
44-
func VerifyURL(rawURL string) error {
45-
_, err := routing.Locate(rawURL)
46-
return err
4730
}

0 commit comments

Comments
 (0)