diff --git a/action/auxi.go b/action/auxi.go index 218b6b88..6e7907c3 100644 --- a/action/auxi.go +++ b/action/auxi.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/essentialkaos/bibop/recipe" + "github.com/essentialkaos/ek/v12/strutil" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -154,6 +155,15 @@ func fmtValue(v string) string { return v } +// fmtHash format SHA-256 hash +func fmtHash(v string) string { + if len(v) < 64 { + return v + } + + return strutil.Head(v, 7) + "…" + strutil.Tail(v, 7) +} + // sanitizeData removes escape characters func sanitizeData(data []byte) []byte { data = bytes.ReplaceAll(data, []byte("\r"), nil) diff --git a/action/fs.go b/action/fs.go index bf72326f..92c3448d 100644 --- a/action/fs.go +++ b/action/fs.go @@ -337,9 +337,15 @@ func Checksum(action *recipe.Action) error { switch { case !action.Negative && fileHash != mustHash: - return fmt.Errorf("File %s has invalid checksum hash (%s ≠ %s)", file, fileHash, mustHash) + return fmt.Errorf( + "File %s has invalid checksum hash (%s ≠ %s)", + file, fmtHash(fileHash), fmtHash(mustHash), + ) case action.Negative && fileHash == mustHash: - return fmt.Errorf("File %s has invalid checksum hash (%s)", file, fileHash) + return fmt.Errorf( + "File %s has invalid checksum hash (%s)", + file, fmtHash(fileHash), + ) } return nil diff --git a/cli/cli.go b/cli/cli.go index c2e1b1bf..c87adbe0 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -44,7 +44,7 @@ import ( // Application info const ( APP = "bibop" - VER = "8.0.5" + VER = "8.1.0" DESC = "Utility for testing command-line tools" ) @@ -404,11 +404,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Print(bash.Generate(info, "bibop", "recipe")) + fmt.Print(bash.Generate(info, APP, "recipe")) case "fish": - fmt.Print(fish.Generate(info, "bibop")) + fmt.Print(fish.Generate(info, APP)) case "zsh": - fmt.Print(zsh.Generate(info, optMap, "bibop", "*.recipe")) + fmt.Print(zsh.Generate(info, optMap, APP, "*.recipe")) default: return 1 }