-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugin): rename to service and cleanup interface
- Loading branch information
Showing
52 changed files
with
756 additions
and
849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package format | ||
|
||
import ( | ||
"github.com/containrrr/shoutrrr/pkg/types" | ||
"strings" | ||
) | ||
|
||
const EnumInvalid = -1 | ||
|
||
type EnumFormatter struct { | ||
names []string | ||
} | ||
|
||
func (ef EnumFormatter) Names() []string { | ||
return ef.names | ||
} | ||
|
||
func (ef EnumFormatter) Print(e int) string { | ||
if e >= len(ef.names) || e < 0 { | ||
return "Invalid" | ||
} | ||
return ef.names[e] | ||
} | ||
|
||
func (ef EnumFormatter) Parse(s string) int { | ||
target := strings.ToLower(s) | ||
for index, name := range ef.names { | ||
if target == strings.ToLower(name) { | ||
return index | ||
} | ||
} | ||
return EnumInvalid | ||
} | ||
|
||
func CreateEnumFormatter(names []string) types.EnumFormatter { | ||
return &EnumFormatter{ | ||
names, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package format | ||
|
||
import ( | ||
"fmt" | ||
"github.com/containrrr/shoutrrr/pkg/types" | ||
) | ||
|
||
// BuildQuery converts the fields of a config object to a delimited query string | ||
func BuildQuery(c types.ServiceConfig) string { | ||
query := "" | ||
fields := c.QueryFields() | ||
format := "%s=%s" | ||
for index, key := range fields { | ||
value, _ := c.Get(key) | ||
if index == 1 { | ||
format = "&%s=%s" | ||
} | ||
query += fmt.Sprintf(format, key, value) | ||
} | ||
|
||
return query | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.