Add Task::Param class
This commit is contained in:
parent
1b3e459ada
commit
67fa432750
@ -166,6 +166,9 @@ EOF
|
|||||||
Task[].each do |name, task|
|
Task[].each do |name, task|
|
||||||
if task.desc
|
if task.desc
|
||||||
usage += %[ #{sprintf("%-27s", name)} #{task.desc}\n]
|
usage += %[ #{sprintf("%-27s", name)} #{task.desc}\n]
|
||||||
|
task.params.each do |name, param|
|
||||||
|
usage += %[ #{sprintf("%-25s", "--#{name}")} #{param.description}]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
usage
|
usage
|
||||||
|
@ -37,6 +37,18 @@ module Rscons
|
|||||||
end.sort
|
end.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Construct a task parameter.
|
||||||
|
#
|
||||||
|
# @param name [String]
|
||||||
|
# Param name.
|
||||||
|
# @param description [String]
|
||||||
|
# Param description.
|
||||||
|
# @param value [String, nil]
|
||||||
|
# Param value.
|
||||||
|
def param(name, description, value)
|
||||||
|
Task::Param.new(name, description, value)
|
||||||
|
end
|
||||||
|
|
||||||
# Return path components from the PATH variable.
|
# Return path components from the PATH variable.
|
||||||
#
|
#
|
||||||
# @return [Array<String>]
|
# @return [Array<String>]
|
||||||
|
@ -49,6 +49,37 @@ module Rscons
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Class to represent a task parameter.
|
||||||
|
class Param
|
||||||
|
|
||||||
|
# @return [String]
|
||||||
|
# Param name.
|
||||||
|
attr_reader :name
|
||||||
|
|
||||||
|
# @return [String]
|
||||||
|
# Param description.
|
||||||
|
attr_reader :description
|
||||||
|
|
||||||
|
# @return [String, nil]
|
||||||
|
# Param value.
|
||||||
|
attr_reader :value
|
||||||
|
|
||||||
|
# Construct a Param.
|
||||||
|
#
|
||||||
|
# @param name [String]
|
||||||
|
# Param name.
|
||||||
|
# @param description [String]
|
||||||
|
# Param description.
|
||||||
|
# @param value [String, nil]
|
||||||
|
# Param value.
|
||||||
|
def initialize(name, description, value)
|
||||||
|
@name = name
|
||||||
|
@description = description
|
||||||
|
@value = value
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Whether to automatically configure before running this task.
|
# Whether to automatically configure before running this task.
|
||||||
attr_reader :autoconf
|
attr_reader :autoconf
|
||||||
@ -65,20 +96,26 @@ module Rscons
|
|||||||
# Task name.
|
# Task name.
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
|
# @return [Hash<String => Param>]
|
||||||
|
# Task params.
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
# Construct a task.
|
# Construct a task.
|
||||||
#
|
#
|
||||||
# @param name [String]
|
# @param name [String]
|
||||||
# Task name.
|
# Task name.
|
||||||
# @param options [Hash]
|
# @param options [Hash]
|
||||||
# Task options.
|
# Options.
|
||||||
# @option options [Boolean] :autoconf
|
# @option options [Boolean] :autoconf
|
||||||
# Whether to automatically configure before running this task (default
|
# Whether to automatically configure before running this task (default
|
||||||
# true).
|
# true).
|
||||||
def initialize(name, options, &block)
|
def initialize(name, options, &block)
|
||||||
@name = name
|
|
||||||
@actions = []
|
|
||||||
@deps = []
|
|
||||||
@autoconf = true
|
@autoconf = true
|
||||||
|
@deps = []
|
||||||
|
@desc = nil
|
||||||
|
@name = name
|
||||||
|
@params = {}
|
||||||
|
@actions = []
|
||||||
Task.register(self)
|
Task.register(self)
|
||||||
modify(options, &block)
|
modify(options, &block)
|
||||||
end
|
end
|
||||||
@ -132,6 +169,11 @@ module Rscons
|
|||||||
if options.include?(:deps)
|
if options.include?(:deps)
|
||||||
@deps += options[:deps]
|
@deps += options[:deps]
|
||||||
end
|
end
|
||||||
|
if options.include?(:params)
|
||||||
|
options[:params].each do |param|
|
||||||
|
@params[param.name] = param
|
||||||
|
end
|
||||||
|
end
|
||||||
if block
|
if block
|
||||||
if env = Environment.open_environment
|
if env = Environment.open_environment
|
||||||
@actions << proc do
|
@actions << proc do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user