diff --git a/internal/batch/batch.go b/internal/batch/batch.go new file mode 100644 index 0000000..3c6541e --- /dev/null +++ b/internal/batch/batch.go @@ -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) +}