make global CLI options available under subcommands - close #86
This commit is contained in:
parent
9f9b7f0bf4
commit
31ef45258f
@ -55,34 +55,37 @@ module Rscons
|
||||
|
||||
private
|
||||
|
||||
def add_global_options(opts)
|
||||
opts.on("-j NTHREADS") do |n_threads|
|
||||
Rscons.application.n_threads = n_threads.to_i
|
||||
end
|
||||
|
||||
opts.on("-r", "--color MODE") do |color_mode|
|
||||
case color_mode
|
||||
when "off"
|
||||
Rscons.application.do_ansi_color = false
|
||||
when "force"
|
||||
Rscons.application.do_ansi_color = true
|
||||
end
|
||||
end
|
||||
|
||||
opts.on("-v", "--verbose") do
|
||||
Rscons.application.verbose = true
|
||||
end
|
||||
end
|
||||
|
||||
def run_toplevel(argv)
|
||||
rsconscript = nil
|
||||
do_help = false
|
||||
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = "Usage: #{$0} [options]"
|
||||
|
||||
add_global_options(opts)
|
||||
|
||||
opts.on("-f FILE") do |f|
|
||||
rsconscript = f
|
||||
end
|
||||
|
||||
opts.on("-j NTHREADS") do |n_threads|
|
||||
Rscons.application.n_threads = n_threads.to_i
|
||||
end
|
||||
|
||||
opts.on("-r", "--color MODE") do |color_mode|
|
||||
case color_mode
|
||||
when "off"
|
||||
Rscons.application.do_ansi_color = false
|
||||
when "force"
|
||||
Rscons.application.do_ansi_color = true
|
||||
end
|
||||
end
|
||||
|
||||
opts.on("-v", "--verbose") do
|
||||
Rscons.application.verbose = true
|
||||
end
|
||||
|
||||
opts.on("--version") do
|
||||
puts "Rscons version #{Rscons::VERSION}"
|
||||
exit 0
|
||||
@ -133,28 +136,27 @@ module Rscons
|
||||
end
|
||||
|
||||
def parse_operation_args(operation, argv)
|
||||
case operation
|
||||
when "configure"
|
||||
parse_configure_args(argv)
|
||||
end
|
||||
end
|
||||
|
||||
def parse_configure_args(argv)
|
||||
options = {}
|
||||
OptionParser.new do |opts|
|
||||
opts.banner = "Usage: #{$0} [options]"
|
||||
|
||||
opts.on("-b", "--build DIR") do |build_dir|
|
||||
options[:build_dir] = build_dir
|
||||
end
|
||||
|
||||
opts.on("--prefix PREFIX") do |prefix|
|
||||
options[:prefix] = prefix
|
||||
add_global_options(opts)
|
||||
case operation
|
||||
when "configure"
|
||||
parse_configure_args(opts, argv, options)
|
||||
end
|
||||
end.order!(argv)
|
||||
options
|
||||
end
|
||||
|
||||
def parse_configure_args(opts, argv, options)
|
||||
opts.on("-b", "--build DIR") do |build_dir|
|
||||
options[:build_dir] = build_dir
|
||||
end
|
||||
|
||||
opts.on("--prefix PREFIX") do |prefix|
|
||||
options[:prefix] = prefix
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1978,6 +1978,13 @@ EOF
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.stdout).to match /gcc.*-o.*simple/
|
||||
end
|
||||
|
||||
it "echoes commands by default with -v after build operation" do
|
||||
test_dir('simple')
|
||||
result = run_rscons(op: %w[build -v])
|
||||
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