How to detect in `show` that you are computing display for the REPL?

Using repr and context:

struct Cyc
    s::String
end

Base.show(io::IO, c::Cyc) =
    print(io, get(io, :style, :plain) ≡ :fancy ? uppercase(c.s) : c.s)

format(c, style) = repr(c; context = :style => style)

Result:

julia> format(Cyc("foo"), :plain)
"foo"

julia> format(Cyc("foo"), :fancy)
"FOO"

julia> format([Cyc("foo") Cyc("bar")], :plain)
"Cyc[foo bar]"

julia> format([Cyc("foo") Cyc("bar")], :fancy)
"Cyc[FOO BAR]"