Add -A CLI flag to show all tasks
This commit is contained in:
parent
ea66501311
commit
59f1a89f4f
@ -54,12 +54,14 @@ module Rscons
|
||||
# List of task(s) to execute.
|
||||
# @param show_tasks [Boolean]
|
||||
# Flag to show tasks and exit.
|
||||
# @param all_tasks [Boolean]
|
||||
# Flag to show all tasks (not just those with a description).
|
||||
# @param enabled_variants [String]
|
||||
# User-specified variants list.
|
||||
#
|
||||
# @return [Integer]
|
||||
# Process exit code (0 on success).
|
||||
def run(rsconscript, tasks_and_params, show_tasks, enabled_variants)
|
||||
def run(rsconscript, tasks_and_params, show_tasks, all_tasks, enabled_variants)
|
||||
Cache.instance["failed_commands"] = []
|
||||
@enabled_variants = enabled_variants
|
||||
if enabled_variants == "" && !tasks_and_params.include?("configure")
|
||||
@ -71,7 +73,7 @@ module Rscons
|
||||
@script.load(rsconscript)
|
||||
enable_variants
|
||||
if show_tasks
|
||||
show_script_tasks
|
||||
show_script_tasks(all_tasks)
|
||||
return 0
|
||||
end
|
||||
apply_task_params(tasks_and_params)
|
||||
@ -340,10 +342,10 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
def show_script_tasks
|
||||
def show_script_tasks(all_tasks)
|
||||
puts "Tasks:"
|
||||
Task[].sort.each do |task_name, task|
|
||||
if task.description
|
||||
if task.description || all_tasks
|
||||
puts %[ #{sprintf("%-27s", task_name)} #{task.description}]
|
||||
task.params.each do |param_name, param|
|
||||
arg_text = "--#{param_name}"
|
||||
|
@ -54,10 +54,15 @@ module Rscons
|
||||
def run_toplevel(argv)
|
||||
rsconscript = nil
|
||||
show_tasks = false
|
||||
all_tasks = false
|
||||
enabled_variants = ""
|
||||
|
||||
OptionParser.new do |opts|
|
||||
|
||||
opts.on("-A", "--all") do
|
||||
all_tasks = true
|
||||
end
|
||||
|
||||
opts.on("-b", "--build DIR") do |build_dir|
|
||||
Rscons.application.build_dir = build_dir
|
||||
end
|
||||
@ -132,7 +137,7 @@ module Rscons
|
||||
end
|
||||
|
||||
begin
|
||||
Rscons.application.run(rsconscript, tasks_and_params, show_tasks, enabled_variants)
|
||||
Rscons.application.run(rsconscript, tasks_and_params, show_tasks, all_tasks, enabled_variants)
|
||||
rescue RsconsError => e
|
||||
Ansi.write($stderr, :red, e.message, :reset, "\n")
|
||||
1
|
||||
@ -144,6 +149,7 @@ module Rscons
|
||||
Usage: #{$0} [global options] [[task] [task options] ...]
|
||||
|
||||
Global options:
|
||||
-A, --all Show all tasks (even without descriptions) in task list
|
||||
-b BUILD, --build=BUILD Set build directory (default: build)
|
||||
-e VS, --variants=VS Enable or disable variants
|
||||
-f FILE Use FILE as Rsconscript
|
||||
|
@ -2956,6 +2956,26 @@ EOF
|
||||
expect(result.stdout).to_not match /^\s*one\b/
|
||||
expect(result.stdout).to_not match /^\s*two\b/
|
||||
end
|
||||
|
||||
context "with -A flag" do
|
||||
it "displays all tasks and their parameters" do
|
||||
test_dir "tasks"
|
||||
result = run_rscons(args: %w[-f tasks.rb -AT])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
verify_lines(lines(result.stdout), [
|
||||
"Tasks:",
|
||||
/\bone\b/,
|
||||
/\btwo\b/,
|
||||
/\bthree\b\s+Task three/,
|
||||
/\bfour\b\s+Task four/,
|
||||
/--myparam=MYPARAM\s+My special parameter/,
|
||||
/--myp2\s+My parameter 2/,
|
||||
/\bfive\b/,
|
||||
/\bsix\b/,
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "download script method" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user