Add Batch implementation with Args, Check, Close, and MoveFile methods
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user