Add Batch implementation with Args, Check, Close, and MoveFile methods

This commit is contained in:
2026-04-26 15:27:31 +05:00
parent 53d8854ab4
commit 6d62b280a1
+32
View File
@@ -0,0 +1,32 @@
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)
}