File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
cmd/wrtag/testdata/scripts Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 88 "fmt"
99 "log/slog"
1010 "os/exec"
11+ "path/filepath"
1112 "strings"
1213
1314 "github.com/google/shlex"
@@ -38,7 +39,8 @@ func NewSubprocAddon(conf string) (SubprocAddon, error) {
3839}
3940
4041const (
41- markerFiles = "<files>"
42+ markerFiles = "<files>"
43+ markerDirectory = "<directory>"
4244)
4345
4446func (s SubprocAddon ) Check () error {
@@ -49,11 +51,22 @@ func (s SubprocAddon) Check() error {
4951}
5052
5153func (s SubprocAddon ) ProcessRelease (ctx context.Context , paths []string ) error {
54+ var pathsDirectory string
55+ for _ , path := range paths {
56+ pd := filepath .Dir (path )
57+ if pathsDirectory != "" && pd != pathsDirectory {
58+ return errors .New ("addon called with paths from two different directories" )
59+ }
60+ pathsDirectory = pd
61+ }
62+
5263 var args []string
5364 for _ , arg := range s .args {
5465 switch arg {
5566 case markerFiles :
5667 args = append (args , paths ... )
68+ case markerDirectory :
69+ args = append (args , pathsDirectory )
5770 default :
5871 args = append (args , arg )
5972 }
Original file line number Diff line number Diff line change 11env WRTAG_PATH_FORMAT='albums/{{ .Release.Title }}/{{ .TrackNum }}{{ .Ext }}'
22env WRTAG_LOG_LEVEL=debug
3- env WRTAG_ADDON='subproc sh -c "true", subproc sh echo-script out <files>'
3+ env WRTAG_ADDON='subproc sh -c "true", subproc sh echo-script out <directory> -- < files>'
44
55exec wrtag -config
6- stdout 'addon.*subproc \("sh" "-c" "true"\), subproc \("sh" "echo-script" "out" "<files>"\)'
6+ stdout 'addon.*subproc \("sh" "-c" "true"\), subproc \("sh" "echo-script" "out" "<directory>" "--" "< files>"\)'
77
88exec tag write 'kat_moda/1.flac'
99exec tag write 'kat_moda/2.flac'
@@ -21,7 +21,9 @@ for f in "$@"; do
2121 echo "${f#$PWD/}" >>"$out"
2222done
2323-- exp-out --
24- got 3 files
24+ got 5 files
25+ albums/Kat Moda
26+ --
2527albums/Kat Moda/1.flac
2628albums/Kat Moda/2.flac
2729albums/Kat Moda/3.flac
You can’t perform that action at this time.
0 commit comments