mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-14 17:07:31 +00:00
4598244167
* Use placeholder as default if field left empty and is required Co-authored-by: mcastorina <m.castorina93@gmail.com> * Drop unused func * uncomment azure source * update wording --------- Co-authored-by: mcastorina <m.castorina93@gmail.com>
28 lines
691 B
Go
28 lines
691 B
Go
package common
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/muesli/reflow/truncate"
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/tui/components/textinputs"
|
|
)
|
|
|
|
// TruncateString is a convenient wrapper around truncate.TruncateString.
|
|
func TruncateString(s string, max int) string {
|
|
if max < 0 {
|
|
max = 0
|
|
}
|
|
return truncate.StringWithTail(s, uint(max), "…")
|
|
}
|
|
|
|
func SummarizeSource(keys []string, inputs map[string]textinputs.Input, labels map[string]string) string {
|
|
summary := strings.Builder{}
|
|
for _, key := range keys {
|
|
if inputs[key].Value != "" {
|
|
summary.WriteString("\t" + labels[key] + ": " + inputs[key].Value + "\n")
|
|
}
|
|
}
|
|
|
|
summary.WriteString("\n")
|
|
return summary.String()
|
|
}
|