validating input files exist

This commit is contained in:
Martyn 2026-05-05 21:41:41 +02:00
parent 97a7bbe29f
commit 0f1637439f
2 changed files with 25 additions and 0 deletions

3
internal/fileflag/go.mod Normal file
View file

@ -0,0 +1,3 @@
module internal/fileflag
go 1.26.2

View file

@ -0,0 +1,22 @@
package fileflag
import "os"
type InputFileFlag string
func (file *InputFileFlag) String() string {
return string(*file)
}
func (file *InputFileFlag) Set(v string) error {
_, err := os.OpenFile(v, os.O_RDONLY, 0o644)
if err != nil {
return err
}
*file = InputFileFlag(v)
return nil
}
func (file *InputFileFlag) Type() string {
return "inputFileName"
}