Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace --quiet with --banner #23343

Merged
merged 10 commits into from
Aug 21, 2017
10 changes: 5 additions & 5 deletions base/client.jl
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ function process_options(opts::JLOptions)
repl = true
startup = (opts.startupfile != 2)
history_file = (opts.historyfile != 0)
quiet = (opts.quiet != 0)
banner = (opts.banner != 0)
color_set = (opts.color != 0)
global have_color = (opts.color == 1)
global is_interactive = (opts.isinteractive != 0)
@@ -317,7 +317,7 @@ function process_options(opts::JLOptions)
break
end
repl |= is_interactive
return (quiet,repl,startup,color_set,history_file)
return (banner,repl,startup,color_set,history_file)
end

function load_juliarc()
@@ -380,7 +380,7 @@ function _start()
opts = JLOptions()
@eval Main include(x) = $include(Main, x)
try
(quiet,repl,startup,color_set,history_file) = process_options(opts)
(banner,repl,startup,color_set,history_file) = process_options(opts)

local term
global active_repl
@@ -393,10 +393,10 @@ function _start()
term = Terminals.TTYTerminal(get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
global is_interactive = true
color_set || (global have_color = Terminals.hascolor(term))
quiet || REPL.banner(term,term)
banner && REPL.banner(term,term)
if term.term_type == "dumb"
active_repl = REPL.BasicREPL(term)
quiet || warn("Terminal not fully functional")
banner && warn("Terminal not fully functional")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit strange to depend on banner for this warning.

Copy link
Member

@StefanKarpinski StefanKarpinski Aug 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but I would argue that's beyond the scope of this PR. It's just that the better option name made it clear how weird it is that this works this way, so that's a good sign for this change. I've opened a separate issue about this: #23380.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quiet could be (in the future) an umbrella option for a bag of others, including banner and supressing this warning above; but until there are more candidates to be controlled by quiet, it seems fine to have banner control this warning.

else
active_repl = REPL.LineEditREPL(term, true)
active_repl.history_file = history_file
2 changes: 1 addition & 1 deletion base/options.jl
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

# NOTE: This type needs to be kept in sync with jl_options in src/julia.h
struct JLOptions
quiet::Int8
banner::Int8
julia_home::Ptr{UInt8}
julia_bin::Ptr{UInt8}
eval::Ptr{UInt8}
4 changes: 2 additions & 2 deletions doc/man/julia.1
Original file line number Diff line number Diff line change
@@ -108,8 +108,8 @@ Run processes on hosts listed in <file>
Interactive mode; REPL runs and isinteractive() is true

.TP
-q, --quiet
Quiet startup without banner
--banner={yes|no}
Enable or disable startup banner

.TP
--color={yes|no}
2 changes: 1 addition & 1 deletion doc/src/manual/getting-started.md
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ julia [switches] -- [programfile] [args...]
--machinefile <file> Run processes on hosts listed in <file>
-i Interactive mode; REPL runs and isinteractive() is true
-q, --quiet Quiet startup (no banner)
--banner={yes|no} Enable or disable startup banner
--color={yes|no} Enable or disable color text
--history-file={yes|no} Load or save history
23 changes: 17 additions & 6 deletions src/jloptions.c
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ JL_DLLEXPORT const char *jl_get_default_sysimg_path(void)
}


jl_options_t jl_options = { 0, // quiet
jl_options_t jl_options = { 1, // banner
NULL, // julia_home
NULL, // julia_bin
NULL, // eval
@@ -102,7 +102,7 @@ static const char opts[] =

// interactive options
" -i Interactive mode; REPL runs and isinteractive() is true\n"
" -q, --quiet Quiet startup (no banner)\n"
" --banner={yes|no} Enable or disable startup banner\n"
" --color={yes|no} Enable or disable color text\n"
" --history-file={yes|no} Load or save history\n\n"

@@ -170,7 +170,8 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
opt_output_ji,
opt_use_precompiled,
opt_use_compilecache,
opt_incremental
opt_incremental,
opt_banner
};
static const char* const shortopts = "+vhqH:e:E:L:J:C:ip:O:g:";
static const struct option longopts[] = {
@@ -180,6 +181,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
{ "version", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' },
{ "quiet", no_argument, 0, 'q' },
{ "banner", required_argument, 0, opt_banner },
{ "home", required_argument, 0, 'H' },
{ "eval", required_argument, 0, 'e' },
{ "print", required_argument, 0, 'E' },
@@ -280,9 +282,6 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
case 'h': // help
jl_printf(JL_STDOUT, "%s%s", usage, opts);
jl_exit(0);
case 'q': // quiet
jl_options.quiet = 1;
break;
case 'g': // debug info
if (optarg != NULL) {
if (!strcmp(optarg,"0"))
@@ -315,6 +314,18 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
jl_options.image_file = strdup(optarg);
jl_options.image_file_specified = 1;
break;
case 'q': // quiet
jl_printf(JL_STDERR, "-q and --quiet are deprecated, use --banner=no instead\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add a comment in the 0.7 section of base/deprecated.jl so this gets staged for removal at the right time

also should add a NEWS.md note about the changed command-line flag

jl_options.banner = 0;
break;
case opt_banner: // banner
if (!strcmp(optarg,"yes"))
jl_options.banner = 1;
else if (!strcmp(optarg,"no"))
jl_options.banner = 0;
else
jl_errorf("julia: invalid argument to --banner={yes|no} (%s)", optarg);
break;
case opt_use_precompiled:
if (!strcmp(optarg,"yes"))
jl_options.use_precompiled = JL_OPTIONS_USE_PRECOMPILED_YES;
2 changes: 1 addition & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
@@ -1671,7 +1671,7 @@ JL_DLLEXPORT void jl_(void *jl_value);
// julia options -----------------------------------------------------------
// NOTE: This struct needs to be kept in sync with JLOptions type in base/options.jl
typedef struct {
int8_t quiet;
int8_t banner;
const char *julia_home;
const char *julia_bin;
const char *eval;
4 changes: 2 additions & 2 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
@test startswith(read(`$exename --help`, String), header)
end

# --quiet
# --banner
# This flag is indirectly tested in test/repl.jl

# --home
@@ -72,7 +72,7 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
end

# --procs
@test readchomp(`$exename -q -p 2 -e "println(nworkers())"`) == "2"
@test readchomp(`$exename --banner=no -p 2 -e "println(nworkers())"`) == "2"
@test !success(`$exename -p 0`)
@test !success(`$exename --procs=1.0`)

4 changes: 2 additions & 2 deletions test/repl.jl
Original file line number Diff line number Diff line change
@@ -614,7 +614,7 @@ let exename = Base.julia_cmd()
TestHelpers.with_fake_pty() do slave, master
nENV = copy(ENV)
nENV["TERM"] = "dumb"
p = spawn(setenv(`$exename --startup-file=no --quiet`,nENV),slave,slave,slave)
p = spawn(setenv(`$exename --startup-file=no --banner=no`,nENV),slave,slave,slave)
output = readuntil(master,"julia> ")
if ccall(:jl_running_on_valgrind,Cint,()) == 0
# If --trace-children=yes is passed to valgrind, we will get a
@@ -631,7 +631,7 @@ let exename = Base.julia_cmd()
end

# Test stream mode
outs, ins, p = readandwrite(`$exename --startup-file=no --quiet`)
outs, ins, p = readandwrite(`$exename --startup-file=no --banner=no`)
write(ins,"1\nquit()\n")
@test read(outs, String) == "1\n"
end # let exename