diff --git a/src/options.jl b/src/options.jl index 54aaed02..f11433b4 100644 --- a/src/options.jl +++ b/src/options.jl @@ -138,6 +138,17 @@ function accum_opt!(d::AbstractDict, opt::AbstractDict) end end +function Base.append!(options::Options, opts) + for opt in opts + accum_opt!(options.dict, opt) + end + options +end + +function Base.push!(options::Options, opts::Union{String,Pair}...) + append!(options, opts) +end + function dictify(args) options = Options() for arg in args diff --git a/test/test_options.jl b/test/test_options.jl index 0a99d2ca..0e3a38ff 100644 --- a/test/test_options.jl +++ b/test/test_options.jl @@ -30,3 +30,10 @@ end @test squashed_repr_tex(@pgf Plot({}, Table([], []))) == "\\addplot[]\ntable[row sep={\\\\}]\n{\n\\\\\n}\n;" # note [] end + +@testset "options push! and append!" begin + opt1 = "color" => "red" + opt2 = "dashed" + @test @pgf(push!({}, opt1, opt2)).dict == Dict([opt1, opt2 => nothing]) + @test @pgf(append!({}, [opt1, opt2])).dict == Dict([opt1, opt2 => nothing]) +end