add verbose CLI option to set Environment default echo mode - close #70
This commit is contained in:
parent
eaac473f44
commit
918c629435
@ -11,6 +11,10 @@ module Rscons
|
||||
# The number of threads to use when scheduling subprocesses.
|
||||
attr_accessor :n_threads
|
||||
|
||||
# @return [Boolean]
|
||||
# Whether to run verbosely.
|
||||
attr_accessor :verbose
|
||||
|
||||
# @return [VarSet]
|
||||
# Access any variables set on the rscons command-line.
|
||||
attr_reader :vars
|
||||
|
@ -8,6 +8,7 @@ Global options:
|
||||
--version Show rscons version and exit
|
||||
-h, --help Show rscons help and exit
|
||||
-r COLOR, --color=COLOR Set color mode (off, auto, force)
|
||||
-v, --verbose Run verbosely
|
||||
|
||||
Operations:
|
||||
configure Configure the project
|
||||
@ -78,6 +79,10 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
opts.on("-v", "--verbose") do
|
||||
Rscons.application.verbose = true
|
||||
end
|
||||
|
||||
opts.on("--version") do
|
||||
puts "Rscons version #{Rscons::VERSION}"
|
||||
exit 0
|
||||
|
@ -81,7 +81,14 @@ module Rscons
|
||||
add_builder(builder_class.new)
|
||||
end
|
||||
end
|
||||
@echo = options[:echo] || :short
|
||||
@echo =
|
||||
if options[:echo]
|
||||
options[:echo]
|
||||
elsif Rscons.application.verbose
|
||||
:command
|
||||
else
|
||||
:short
|
||||
end
|
||||
@build_root = "#{Cache.instance.configuration_data["build_dir"]}/e.#{@id}"
|
||||
|
||||
if block_given?
|
||||
|
@ -1957,4 +1957,27 @@ EOF
|
||||
end
|
||||
end
|
||||
|
||||
context "verbose option" do
|
||||
it "does not echo commands when verbose options not given" do
|
||||
test_dir('simple')
|
||||
result = run_rscons
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to match /CC .*simple\.o/
|
||||
end
|
||||
|
||||
it "echoes commands by default with -v" do
|
||||
test_dir('simple')
|
||||
result = run_rscons(rscons_args: %w[-v])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to match /gcc.*-o.*simple/
|
||||
end
|
||||
|
||||
it "echoes commands by default with --verbose" do
|
||||
test_dir('simple')
|
||||
result = run_rscons(rscons_args: %w[--verbose])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to match /gcc.*-o.*simple/
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user