feat(actions): add more macro variables (#157)

* feat(actions): add more macro variables

* feat: add more macros

* feat: add more tests
This commit is contained in:
Ludvig Lundgren 2022-03-04 20:29:53 +01:00 committed by GitHub
parent e0e4bf6202
commit 5a45851677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 252 additions and 68 deletions

View file

@ -10,7 +10,7 @@ import (
"github.com/rs/zerolog/log"
)
func (s *service) execCmd(release domain.Release, action domain.Action, torrentFile string) {
func (s *service) execCmd(release domain.Release, action domain.Action) {
log.Debug().Msgf("action exec: %v release: %v", action.Name, release.TorrentName)
// check if program exists
@ -21,11 +21,7 @@ func (s *service) execCmd(release domain.Release, action domain.Action, torrentF
}
// handle args and replace vars
m := Macro{
TorrentName: release.TorrentName,
TorrentPathName: torrentFile,
TorrentUrl: release.TorrentURL,
}
m := NewMacro(release)
// parse and replace values in argument string before continuing
parsedArgs, err := m.Parse(action.ExecArgs)
@ -46,7 +42,7 @@ func (s *service) execCmd(release domain.Release, action domain.Action, torrentF
output, err := command.CombinedOutput()
if err != nil {
// everything other than exit 0 is considered an error
log.Error().Stack().Err(err).Msgf("command: %v args: %v failed, torrent: %v", cmd, parsedArgs, torrentFile)
log.Error().Stack().Err(err).Msgf("command: %v args: %v failed, torrent: %v", cmd, parsedArgs, release.TorrentTmpFile)
}
log.Trace().Msgf("executed command: '%v'", string(output))