Skip to content

Commit 156ead2

Browse files
committed
Add get/0 and set/0
1 parent 7ea8fae commit 156ead2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/iex/lib/iex/options.ex

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ defmodule IEx.Options do
4141
],
4242
]
4343

44+
@doc """
45+
Returns all supported IEx options with their respective values as a keyword
46+
list.
47+
"""
48+
def get do
49+
Enum.map list(), fn name ->
50+
{name, get(name)}
51+
end
52+
end
53+
4454
@doc """
4555
Get current value of the option `name`. Raises ArgumentError if name is not a
4656
known option.
@@ -60,6 +70,18 @@ defmodule IEx.Options do
6070
raise_option(name)
6171
end
6272

73+
@doc """
74+
Set all options at once by providing a keyword list with option names and
75+
their corresponding values. This is generally obtained from `get/0`.
76+
77+
Returns a keyword list of old option values.
78+
"""
79+
def set(opts) do
80+
Enum.map opts, fn {name, val} ->
81+
{name, set(name, val)}
82+
end
83+
end
84+
6385
@doc """
6486
Sets the value for the option `name` to `value`.
6587

0 commit comments

Comments
 (0)