validating input files exist
This commit is contained in:
parent
97a7bbe29f
commit
0f1637439f
2 changed files with 25 additions and 0 deletions
3
internal/fileflag/go.mod
Normal file
3
internal/fileflag/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
module internal/fileflag
|
||||||
|
|
||||||
|
go 1.26.2
|
||||||
22
internal/fileflag/inputfileflag.go
Normal file
22
internal/fileflag/inputfileflag.go
Normal 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"
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue