33 lines
591 B
Go
33 lines
591 B
Go
package batch
|
|
|
|
import (
|
|
"git.kor-elf.net/kor-elf-shield/go-nftables-client/contract"
|
|
"git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/pkg"
|
|
)
|
|
|
|
type batch struct {
|
|
file *pkg.File
|
|
}
|
|
|
|
func NewBatch(file *pkg.File) contract.Batch {
|
|
return &batch{
|
|
file: file,
|
|
}
|
|
}
|
|
|
|
func (b *batch) Args() []string {
|
|
return []string{"-f", b.file.Path()}
|
|
}
|
|
|
|
func (b *batch) Check(command contract.Command) error {
|
|
return command.Run("-c", "-f", b.file.Path())
|
|
}
|
|
|
|
func (b *batch) Close() error {
|
|
return b.file.Remove()
|
|
}
|
|
|
|
func (b *batch) MoveFile(path string) error {
|
|
return b.file.Move(path)
|
|
}
|