Skip to content

Commit a3b8882

Browse files
committed
Bubble up missing flag errors
1 parent e45c3c7 commit a3b8882

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

cmd/checksum.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ func GetChecksum(value []byte, hashFn string) string {
3737
func ChecksumRun(cmd *cobra.Command, args []string) error {
3838

3939
filename, _ := cmd.Flags().GetString("file")
40-
4140
fs := File(filename).CheckFile()
4241

4342
if fs.Err != nil {
44-
fmt.Println(fs.Err)
4543
return fs.Err
4644
} else {
4745

@@ -58,6 +56,10 @@ func ChecksumRun(cmd *cobra.Command, args []string) error {
5856
}
5957
}
6058

59+
if algorithmFlag == "" {
60+
return fmt.Errorf("Checksum flag is missing. One of md5, sha1, sha256 is required.")
61+
}
62+
6163
fmt.Println(GetChecksum(contents, algorithmFlag))
6264
}
6365

0 commit comments

Comments
 (0)