Skip to content

Commit 3e9b618

Browse files
committed
Deprecate IEx.inspect_opts in favor of IEx.Options
1 parent 9f862be commit 3e9b618

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

lib/iex/lib/iex.ex

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,16 @@ defmodule IEx do
147147
match?({ :ok, true }, :application.get_env(:iex, :started))
148148
end
149149
150-
@doc """
151-
Registers options used on inspect.
152-
"""
150+
@doc false
153151
def inspect_opts(opts) when is_list(opts) do
154-
old_opts = inspect_opts()
155-
filtered_opts = Enum.filter opts, fn {name, _} ->
156-
name in old_opts
157-
end
158-
:application.set_env(:iex, :inspect_opts, Keyword.merge(old_opts, filtered_opts))
152+
IO.write "[WARNING] IEx.inspect_opts is deprecated, please use IEx.Options.get/set instead. See `IEx.Options.print_help :inspect`.\n#{Exception.format_stacktrace}"
153+
IEx.Options.set :inspect, opts
159154
end
160155
161-
@doc """
162-
Returns currently registered inspect options.
163-
"""
156+
@doc false
164157
def inspect_opts do
165-
{ :ok, opts } = :application.get_env(:iex, :inspect_opts)
166-
opts
158+
IO.write "[WARNING] IEx.inspect_opts is deprecated, please use IEx.Options.get/set instead. See `IEx.Options.print_help :inspect`.\n#{Exception.format_stacktrace}"
159+
IEx.Options.get :inspect
167160
end
168161
169162
# This is a callback invoked by Erlang shell utilities
@@ -207,7 +200,7 @@ defmodule IEx do
207200
)
208201
209202
if opts[:inspect_opts] do
210-
IEx.inspect_opts(opts[:inspect_opts])
203+
IEx.Options.set :inspect, opts[:inspect_opts]
211204
end
212205
213206
IEx.Config[

lib/iex/lib/iex/options.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ defmodule IEx.Options do
9393
end
9494

9595
def get(:inspect) do
96-
IEx.inspect_opts
96+
{ :ok, opts } = :application.get_env(:iex, :inspect_opts)
97+
opts
9798
end
9899

99100
def get(name) do
@@ -122,7 +123,7 @@ defmodule IEx.Options do
122123
def set(name, value)
123124

124125
def set(:colors, colors) when is_list(colors) do
125-
{ :ok, old_colors } = :application.get_env(:iex, :colors)
126+
old_colors = get(:colors)
126127
# Validate keys before setting
127128
filtered_colors = Enum.filter colors, fn {name, _} ->
128129
name in old_colors
@@ -136,9 +137,12 @@ defmodule IEx.Options do
136137
end
137138

138139
def set(:inspect, opts) when is_list(opts) do
139-
old_opts = IEx.inspect_opts
140-
# `opts` are validated by IEx.inspect_opts
141-
IEx.inspect_opts(opts)
140+
old_opts = get(:inspect)
141+
# Validate keys before setting
142+
filtered_opts = Enum.filter opts, fn {name, _} ->
143+
name in old_opts
144+
end
145+
:application.set_env(:iex, :inspect_opts, Keyword.merge(old_opts, filtered_opts))
142146
old_opts
143147
end
144148

lib/iex/lib/iex/server.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ defmodule IEx.Server do
157157
end
158158

159159
defp io_put(result) do
160-
IO.puts :stdio, IEx.color(:eval_result, inspect(result, IEx.inspect_opts))
160+
IO.puts :stdio, IEx.color(:eval_result, inspect(result, IEx.Options.get(:inspect)))
161161
end
162162

163163
defp io_error(result) do

0 commit comments

Comments
 (0)