Documentation
¶
Index ¶
Constants ¶
View Source
const BASE_PLACEHOLDER = "{{base}}"
View Source
const EXT_PLACEHOLDER = "{{ext}}"
View Source
const INPUT_PLACEHOLDER = "{{input}}"
View Source
const OUTPUT_PLACEHOLDER = "{{output}}"
Variables ¶
View Source
var (
ErrNoOutputFile = fmt.Errorf("no target output file exists")
)
Functions ¶
func Transformer ¶
func Transformer(tc *transform.TransformerContext) (changed bool, err error)
对每个文件执行外部命令以替换文件内容
Types ¶
type ExecutorOptions ¶
type ExecutorOptions struct { // do create hardlink for each file before handling it. a workaround. // the hardlink file will be inside tmpdir and with name <hash>.ext. // <hash> is the md5 hash hex string of original basename without ext. Hardlink bool Binary string // external binary Func func(inputFile, outputFile string, options url.Values, logger transform.Logger) (changed bool, err error) // Original input file can be accessed from options.Get("input") ContentsFunc func(input []byte, options url.Values, logger transform.Logger) (output []byte, changed bool, err error) BinaryArgs []string // must contains input & output placeholder Ext []string // file exts that can be processed. MinSize int64 MaxSize int64 NewExt string // replace with this new ext Output string // output filename. placeholders: {{base}}, {{ext}}. E.g. "{{base}}.flac". // E.g. if have a value: []string{".vtt"}, // if "foo.wav" was converted to "foo.flac" (a new name file), // then "foo.wav.vtt" file, if it exists, will be renamed to "foo.flac.vtt" accordingly. RenameAdditionalSuffixes []string // Only applies for Binary executor. // If returned newArgs is not nil and err is nil, will re-try execute binary use newArgs. // If return (nil,nil), will ignore current ierr and skip current input file. OnError func(combinedOutput []byte, ierr error, logger transform.Logger) (newArgs []string, err error) Test func(path string) bool }
func (*ExecutorOptions) Transformer ¶
func (options *ExecutorOptions) Transformer(tc *transform.TransformerContext) (changed bool, err error)
internal Transformer
Click to show internal directories.
Click to hide internal directories.