mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
Feature: Exec action (#7)
* feat: implement exec action * chore: change logs to trace * refactor: extract from action
This commit is contained in:
parent
4c19187a2f
commit
9eccc6b5e2
8 changed files with 340 additions and 157 deletions
30
internal/action/macros.go
Normal file
30
internal/action/macros.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package action
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
type Macro struct {
|
||||
TorrentName string
|
||||
TorrentPathName string
|
||||
TorrentUrl string
|
||||
}
|
||||
|
||||
// Parse takes a string and replaces valid vars
|
||||
func (m Macro) Parse(text string) (string, error) {
|
||||
|
||||
// setup template
|
||||
tmpl, err := template.New("macro").Parse(text)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var tpl bytes.Buffer
|
||||
err = tmpl.Execute(&tpl, m)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return tpl.String(), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue