Skip to content

Commit afabdc2

Browse files
committed
Changed _split_arguments to prevent crash on '-' and improper handling of arguments containing '='
1 parent d522ec0 commit afabdc2

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArgMacros"
22
uuid = "dbc42088-9de8-42a0-8ec8-2cd114e1ea3e"
33
authors = ["zachmatson"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
TextWrap = "b718987f-49a8-5099-9789-dcd902bef87d"

src/argsparsing.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,24 @@ function _split_arguments(args::Vector{String})::Vector{String}
3333
splitargs = Vector{String}()
3434

3535
for arg in args
36-
# Expand arg/value pairs with = to separate entries
37-
for splitarg in split(arg, '=')
36+
# Flags/options
37+
if arg[1] == '-'
38+
arg_split = split(arg, '=', limit=2)::Vector{SubString{String}}
39+
3840
# Handle chained flags or flags with Int values like "-xzfv" or "-O3"
39-
if splitarg[1] == '-' && splitarg[2] != '-' && length(splitarg) > 2
40-
append!(splitargs, _split_multiflag(splitarg))
41+
if length(arg_split[1]) > 2 && arg_split[1][2] != '-'
42+
append!(splitargs, _split_multiflag(arg_split[1]))
43+
44+
if length(arg_split) == 2
45+
push!(splitargs, arg_split[2])
46+
end
47+
# Handle other flags
4148
else
42-
push!(splitargs, splitarg)
49+
append!(splitargs, arg_split)
4350
end
51+
# Values
52+
else
53+
push!(splitargs, arg)
4454
end
4555
end
4656

0 commit comments

Comments
 (0)