Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ function exec_options(opts)
end
end
if repl || is_interactive::Bool
if interactiveinput
banner = (opts.banner != 0) # --banner!=no
else
banner = (opts.banner == 1) # --banner=yes
end
b = opts.banner
auto = b == -1
banner = b == 0 || (auto && !interactiveinput) ? :no :
b == 1 || (auto && interactiveinput) ? :yes :
:short # b == 2
run_main_repl(interactiveinput, quiet, banner, history_file, color_set)
end
nothing
Expand Down Expand Up @@ -409,14 +409,14 @@ end
global active_repl

# run the requested sort of evaluation loop on stdio
function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
function run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool, color_set::Bool)
load_InteractiveUtils()

if interactive && isassigned(REPL_MODULE_REF)
invokelatest(REPL_MODULE_REF[]) do REPL
term_env = get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb")
term = REPL.Terminals.TTYTerminal(term_env, stdin, stdout, stderr)
banner && Base.banner(term)
banner == :no || Base.banner(term, short=banner==:short)
if term.term_type == "dumb"
repl = REPL.BasicREPL(term)
quiet || @warn "Terminal not fully functional"
Expand All @@ -436,7 +436,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil
if interactive && !quiet
@warn "REPL provider not available: using basic fallback"
end
banner && Base.banner()
banner == :no || Base.banner(short=banner==:short)
let input = stdin
if isa(input, File) || isa(input, IOStream)
# for files, we can slurp in the whole thing at once
Expand Down
58 changes: 36 additions & 22 deletions base/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ end

libllvm_path() = ccall(:jl_get_libllvm, Any, ())

function banner(io::IO = stdout)
function banner(io::IO = stdout; short = false)
if GIT_VERSION_INFO.tagged_commit
commit_string = TAGGED_RELEASE_BANNER
elseif isempty(GIT_VERSION_INFO.commit)
Expand Down Expand Up @@ -298,27 +298,41 @@ function banner(io::IO = stdout)
d3 = c[:bold] * c[:green] # third dot
d4 = c[:bold] * c[:magenta] # fourth dot

print(io,""" $(d3)_$(tx)
$(d1)_$(tx) $(jl)_$(tx) $(d2)_$(d3)(_)$(d4)_$(tx) | Documentation: https://docs.julialang.org
$(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) |
$(jl)_ _ _| |_ __ _$(tx) | Type \"?\" for help, \"]?\" for Pkg help.
$(jl)| | | | | | |/ _` |$(tx) |
$(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date)
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string)
$(jl)|__/$(tx) |

""")
if short
print(io,"""
$(d3)o$(tx) | Version $(VERSION)$(commit_date)
$(d2)o$(tx) $(d4)o$(tx) | $(commit_string)
""")
else
print(io,""" $(d3)_$(tx)
$(d1)_$(tx) $(jl)_$(tx) $(d2)_$(d3)(_)$(d4)_$(tx) | Documentation: https://docs.julialang.org
$(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) |
$(jl)_ _ _| |_ __ _$(tx) | Type \"?\" for help, \"]?\" for Pkg help.
$(jl)| | | | | | |/ _` |$(tx) |
$(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date)
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string)
$(jl)|__/$(tx) |

""")
end
else
print(io,"""
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type \"?\" for help, \"]?\" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version $(VERSION)$(commit_date)
_/ |\\__'_|_|_|\\__'_| | $(commit_string)
|__/ |

""")
if short
print(io,"""
o | Version $(VERSION)$(commit_date)
o o | $(commit_string)
""")
else
print(io,"""
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type \"?\" for help, \"]?\" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version $(VERSION)$(commit_date)
_/ |\\__'_|_|_|\\__'_| | $(commit_string)
|__/ |

""")
end
end
end
7 changes: 5 additions & 2 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ static const char opts[] =
// interactive options
" -i, --interactive Interactive mode; REPL runs and `isinteractive()` is true\n"
" -q, --quiet Quiet startup: no banner, suppress REPL warnings\n"
" --banner={yes|no|auto*} Enable or disable startup banner\n"
" --banner={yes|no|short|auto*}\n"
" Enable or disable startup banner\n"
" --color={yes|no|auto*} Enable or disable color text\n"
" --history-file={yes*|no} Load or save history\n\n"

Expand Down Expand Up @@ -444,8 +445,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
jl_options.banner = 0;
else if (!strcmp(optarg, "auto"))
jl_options.banner = -1;
else if (!strcmp(optarg, "short"))
jl_options.banner = 2;
else
jl_errorf("julia: invalid argument to --banner={yes|no|auto} (%s)", optarg);
jl_errorf("julia: invalid argument to --banner={yes|no|auto|short} (%s)", optarg);
break;
case opt_sysimage_native_code:
if (!strcmp(optarg,"yes"))
Expand Down
23 changes: 13 additions & 10 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,19 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
end

# --quiet, --banner
let t(q,b) = "Base.JLOptions().quiet == $q && Base.JLOptions().banner == $b"
@test success(`$exename -e $(t(0, -1))`)
@test success(`$exename -q -e $(t(1, 0))`)
@test success(`$exename --quiet -e $(t(1, 0))`)
@test success(`$exename --banner=no -e $(t(0, 0))`)
@test success(`$exename --banner=yes -e $(t(0, 1))`)
@test success(`$exename -q --banner=no -e $(t(1, 0))`)
@test success(`$exename -q --banner=yes -e $(t(1, 1))`)
@test success(`$exename --banner=no -q -e $(t(1, 0))`)
@test success(`$exename --banner=yes -q -e $(t(1, 1))`)
let p = "print((Base.JLOptions().quiet, Base.JLOptions().banner))"
@test read(`$exename -e $p`, String) == "(0, -1)"
@test read(`$exename -q -e $p`, String) == "(1, 0)"
@test read(`$exename --quiet -e $p`, String) == "(1, 0)"
@test read(`$exename --banner=no -e $p`, String) == "(0, 0)"
@test read(`$exename --banner=yes -e $p`, String) == "(0, 1)"
@test read(`$exename --banner=short -e $p`, String) == "(0, 2)"
@test read(`$exename -q --banner=no -e $p`, String) == "(1, 0)"
@test read(`$exename -q --banner=yes -e $p`, String) == "(1, 1)"
@test read(`$exename -q --banner=short -e $p`, String) == "(1, 2)"
@test read(`$exename --banner=no -q -e $p`, String) == "(1, 0)"
@test read(`$exename --banner=yes -q -e $p`, String) == "(1, 1)"
@test read(`$exename --banner=short -q -e $p`, String) == "(1, 2)"
end

# --home
Expand Down
7 changes: 6 additions & 1 deletion test/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ end
import Base.banner
io = IOBuffer()
@test banner(io) === nothing
@test length(String(take!(io))) > 50
seek(io, 0)
@test countlines(io) == 9
take!(io)
@test banner(io; short=true) === nothing
seek(io, 0)
@test countlines(io) == 2

# julia_version.h version test
@test VERSION.major == ccall(:jl_ver_major, Cint, ())
Expand Down