aboutsummaryrefslogtreecommitdiff
path: root/cli_args.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-08-10 19:42:33 +0200
committerJakob Unterwurzacher2021-08-10 19:42:33 +0200
commit0c16616117e9866cc49adc85738e3c9e3adf413a (patch)
tree5030b1bad61e22870ad724299e9d0b3c2827882b /cli_args.go
parent463f6e8962d87bf45dccd806822d40cfff335695 (diff)
main: add testcases for convertToDoubleDash & parseCliOpts
Diffstat (limited to 'cli_args.go')
-rw-r--r--cli_args.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/cli_args.go b/cli_args.go
index 5ff1861..fa9e35c 100644
--- a/cli_args.go
+++ b/cli_args.go
@@ -114,9 +114,15 @@ func prefixOArgs(osArgs []string) ([]string, error) {
func convertToDoubleDash(osArgs []string) (out []string) {
out = append(out, osArgs...)
for i, v := range out {
+ // Leave "-h" alone so the help text keeps working
if v == "-h" {
continue
}
+ // Don't touch anything after "--"
+ if v == "--" {
+ break
+ }
+ // Convert "-foo" to "--foo"
if len(v) >= 2 && v[0] == '-' && v[1] != '-' {
out[i] = "-" + out[i]
}
@@ -125,11 +131,11 @@ func convertToDoubleDash(osArgs []string) (out []string) {
}
// parseCliOpts - parse command line options (i.e. arguments that start with "-")
-func parseCliOpts() (args argContainer) {
+func parseCliOpts(osArgs []string) (args argContainer) {
var err error
var opensslAuto string
- osArgsPreprocessed, err := prefixOArgs(os.Args)
+ osArgsPreprocessed, err := prefixOArgs(osArgs)
if err != nil {
tlog.Fatal.Println(err)
os.Exit(exitcodes.Usage)