nitc :: ToolContext :: process_options
# Parse and process the options given on the command line
fun process_options(args: Sequence[String])
do
self.opt_warn.value = 1
# init options
option_context.parse(args)
if opt_help.value then
usage
exit 0
end
if opt_version.value then
print version
exit 0
end
if opt_bash_completion.value then
var bash_completion = new BashCompletion(self)
bash_completion.write_to(sys.stdout)
exit 0
end
if opt_stub_man.value then
print """
# NAME
{{{tooldescription.split("\n")[1]}}}
# SYNOPSYS
# OPTIONS
"""
for o in option_context.options do
var first = true
printn "### "
for n in o.names do
if first then first = false else printn ", "
printn "`{n}`"
end
print ""
print "{o.helptext}."
print ""
end
print """
# SEE ALSO
The Nit language documentation and the source code of its tools and libraries may be downloaded from <http://nitlanguage.org>"""
exit 0
end
var errors = option_context.errors
if not errors.is_empty then
for e in errors do print "Error: {e}"
print tooldescription
print "Use --help for help"
exit 1
end
nit_dir = locate_nit_dir
if option_context.rest.is_empty and not accept_no_arguments then
print tooldescription
print "Use --help for help"
exit 1
end
# Set verbose level
verbose_level = opt_verbose.value
if opt_keep_going.value then keep_going = true
if self.opt_quiet.value then self.opt_warn.value = 0
if opt_log_dir.value != null then log_directory = opt_log_dir.value.as(not null)
if opt_log.value then
# Make sure the output directory exists
log_directory.mkdir
# Redirect the verbose messages
log_info = (log_directory/"info.txt").to_path.open_wo
end
end
src/toolcontext.nit:451,2--534,4
redef fun process_options(args)
do
super
for v in opt_disable_phase.value do
if v == "list" then
for p in phases_list do
var deps = p.in_hierarchy.direct_greaters
if deps.is_empty then
print p
else
print "{p} (dep: {deps.join(", ")})"
end
end
exit 0
end
var found = false
for p in phases do
if v != p.to_s then continue
found = true
p.disabled = true
end
if not found then fatal_error(null, "Error: no phase named `{v}`. Use `list` to list all phases.")
end
if opt_sloppy.value then semantize_is_lazy = true
end
src/phase.nit:43,2--70,4
redef fun process_options(args)
do
super
var val = self.opt_dir.value
if val != null then
val = val.simplify_path
val.mkdir
self.output_dir = val
end
end
src/metrics/metrics_base.nit:92,2--101,4
redef fun process_options(args)
do
super
if opt_output.value != null and opt_dir.value != null then
print "Option Error: cannot use both --dir and --output"
exit(1)
end
if opt_no_check_all.value then
opt_no_check_covariance.value = true
opt_no_check_attr_isset.value = true
opt_no_check_assert.value = true
opt_no_check_autocast.value = true
opt_no_check_null.value = true
end
end
src/compiler/abstract_compiler.nit:100,2--116,4
redef fun process_options(args)
do
super
var tc = self
if tc.opt_semi_global.value then
tc.opt_inline_coloring_numbers.value = true
tc.opt_inline_some_methods.value = true
tc.opt_direct_call_monomorph.value = true
tc.opt_skip_dead_methods.value = true
end
if tc.opt_link_boost.value then
tc.opt_colors_are_symbols.value = true
tc.opt_substitute_monomorph.value = true
end
if tc.opt_substitute_monomorph.value then
tc.opt_trampoline_call.value = true
end
end
src/compiler/separate_compiler.nit:80,2--98,4
redef fun process_options(args)
do
super
if opt_no_check_all.value then
opt_no_check_erasure_cast.value = true
end
# Temporary disabled. TODO: implement tagging in the erasure compiler.
if opt_erasure.value then
opt_no_tag_primitives.value = true
end
end
src/compiler/separate_erasure_compiler.nit:35,2--47,4
redef fun process_options(args)
do
super
var sum = opt_separate.value.to_i + opt_erasure.value.to_i
if sum > 1 then
print "Options --separate and --erasure are exclusive"
exit(1)
else if sum == 0 then
# --separate by default
opt_separate.value = true
end
end
src/nith.nit:29,2--41,4
redef fun process_options(args)
do
super
var sum = opt_global.value.to_i + opt_separate.value.to_i + opt_erasure.value.to_i
if sum > 1 then
print "Options --global, --separate and --erasure are exclusive"
exit(1)
else if sum == 0 then
# --separate by default
opt_separate.value = true
end
end
src/nitc.nit:25,2--37,4