added overwirte output file option to hash pass
sophuwu sophie@sophuwu.com
Sat, 12 Jul 2025 01:11:23 +0200
2 files changed,
10 insertions(+),
1 deletions(-)
M
hashpw/hashpw.go
→
hashpw/hashpw.go
@@ -91,7 +91,11 @@ }
if output != "" { _, err = os.Stat(output) if !errors.Is(err, os.ErrNotExist) { - fatal(errors.New("output file already exists: "+output), "invalid output") + fmt.Printf("output file already exists, do you want to overwrite it? (y/n) ") + line, _ := parsers.ReadLineString(os.Stdin) + if line == "y" { + fmt.Printf("\roverwriting: %s\n", output) + } } return func(w []byte) error { f, e := os.Create(output)
M
parsers/parsers.go
→
parsers/parsers.go
@@ -106,3 +106,8 @@ return ret, err
} } } + +func ReadLineString(reader io.Reader) (string, error) { + line, err := ReadLine(reader) + return string(line), err +}