Class: LogicalConstruct::Target::CommandLine
- Inherits:
-
Rake::Application
- Object
- Rake::Application
- LogicalConstruct::Target::CommandLine
- Defined in:
- lib/logical-construct/target/command-line.rb
Instance Method Summary collapse
- #add_options(options) ⇒ Object
- #collect_plan_option(name, value) ⇒ Object
- #collect_tasks ⇒ Object
- #forward_to_plans(options) ⇒ Object
- #go ⇒ Object
-
#initialize(argv) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #mirror_to_plans(options) ⇒ Object
- #mutate_options(patterns, options, &block) ⇒ Object
- #standard_rake_options ⇒ Object
Constructor Details
#initialize(argv) ⇒ CommandLine
6 7 8 9 10 11 12 |
# File 'lib/logical-construct/target/command-line.rb', line 6 def initialize(argv) @argv = argv @manifest_path = nil @flight_deck_tasks = [] = [] super() end |
Instance Method Details
#add_options(options) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/logical-construct/target/command-line.rb', line 75 def () return + [ [ "--control-task", "-C TASK", "Alter the tasks run by flight-deck itself (rather than task run by the plans)", lambda{|value| @flight_deck_tasks << value} ], [ "--manifest-file", "-M MANIFEST", "Supply a starting server manifest (gotten from e.g. AWS userdata)", lambda{|value| @manifest_path = value } ] ] end |
#collect_plan_option(name, value) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/logical-construct/target/command-line.rb', line 46 def collect_plan_option(name, value) if value == true or value.nil? or value.empty? << name else << "#{name}=#{value}" end end |
#collect_tasks ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/logical-construct/target/command-line.rb', line 26 def collect_tasks super @implement_tasks = @top_level_tasks @top_level_tasks = @flight_deck_tasks if @top_level_tasks.empty? @top_level_tasks = ['implement'] end end |
#forward_to_plans(options) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/logical-construct/target/command-line.rb', line 54 def forward_to_plans() patterns = %w{--prereqs} = [] patterns.each do |switch| option = .find{|list| /^#{switch}/ =~ list[0]} next if option.nil? << [option[0].sub(/^--/, "--flight-deck-"), option[-2], option[-1]] end + (patterns, ) do |switch, previous_handler, value| collect_plan_option(switch, value) end end |
#go ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/logical-construct/target/command-line.rb', line 14 def go init(File::basename($0)) Rake.application = self FlightDeck.new do |control| control.namespace_name = nil control.top_level_tasks = @implement_tasks control.manifest_path = @manifest_path control. = end top_level end |
#mirror_to_plans(options) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/logical-construct/target/command-line.rb', line 68 def mirror_to_plans() (%w{--trace}, ) do |switch, previous_handler, value| previous_handler[value] collect_plan_option(switch, value) end end |
#mutate_options(patterns, options, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/logical-construct/target/command-line.rb', line 35 def (patterns, , &block) patterns.each do |switch| option = .find{|list| /^#{switch}/ =~ list[0]} next if option.nil? previous_handler = option.pop option.push lambda{|value| yield(switch, previous_handler, value)} lambda{|value| << "#{switch}=#{value}"} end end |
#standard_rake_options ⇒ Object
85 86 87 |
# File 'lib/logical-construct/target/command-line.rb', line 85 def ( ( forward_to_plans( mirror_to_plans( super)))) end |