git.sophuwu.com > gophuwu
added overwirte output file option to hash pass
sophuwu sophie@sophuwu.com
Sat, 12 Jul 2025 01:11:23 +0200
commit

1d1d6daa6d8fdd25d18a0bd7420fbebf6bf64bd0

parent

65e4a11e06aa7c275eed7bce403c360d2238b5b3

2 files changed, 10 insertions(+), 1 deletions(-)

jump to
M hashpw/hashpw.gohashpw/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.goparsers/parsers.go

@@ -106,3 +106,8 @@ return ret, err

} } } + +func ReadLineString(reader io.Reader) (string, error) { + line, err := ReadLine(reader) + return string(line), err +}