From a71f1c0105e291f117d8a52318f58554f19e9b03 Mon Sep 17 00:00:00 2001 From: Stephen Haywood Date: Mon, 14 Sep 2020 16:13:21 -0400 Subject: [PATCH] Comma separated -w flags (#294) * Comma separated -w flags. * Remove printf * Updated changelog and contributors * Alphabetical order --- CHANGELOG.md | 1 + CONTRIBUTORS.md | 1 + main.go | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 101519b..97a7385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Changed - Pre-flight errors are now displayed also after the usage text to prevent the need to scroll through backlog. + - The `-w` flag now accepts comma delimited values in the form of `file1:W1,file2:W2`. - v1.1.0 - New diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 73997f1..ac9805a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,4 +1,5 @@ # Contributors +* [AverageSecurityGuy](https://github.com/averagesecurityguy) * [bjhulst](https://github.com/bjhulst) * [bsysop](https://twitter.com/bsysop) * [ccsplit](https://github.com/ccsplit) diff --git a/main.go b/main.go index 9e5f60a..a4ee43a 100644 --- a/main.go +++ b/main.go @@ -58,7 +58,14 @@ func (m *multiStringFlag) String() string { } func (m *multiStringFlag) Set(value string) error { - *m = append(*m, value) + delimited := strings.Split(value, ",") + + if len(delimited) > 1 { + *m = append(*m, delimited...) + } else { + *m = append(*m, value) + } + return nil }