Sha256: f57b6c30be96b4b9b3bf28bb11d858aa384597e947457c5accdcf186e5e3cf95

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby

libdir = File.expand_path(File.dirname(__FILE__))
require "#{libdir}/../lib/sfp"

# application mode
if ARGV.length > 1 and ARGV[0] == '-p'
	home_dir = File.expand_path(File.dirname(ARGV[1]))
	parser = Sfp::Parser.new({:home_dir => home_dir})
	parser.parse(File.read(ARGV[1]))
	puts parser.to_json({:pretty => true})

elsif ARGV.length > 1 and ARGV[0] == '--exec-ruby'
	planner = Sfp::Planner.new
	plan = planner.solve({:file => ARGV[1]})
	puts plan.inspect
	executor = Sfp::RubyExecutor.new
	executor.execute_plan({:plan => plan})

elsif ARGV.length > 1 and ARGV[0] == '--exec-bash'
	planner = Sfp::Planner.new
	plan = planner.solve({:file => ARGV[1]})
	puts "Plan: #{plan.inspect}"
	executor = Sfp::BashExecutor.new
	puts "Execution:"
	executor.execute_plan({:plan => plan, :print_output => true})

elsif ARGV.length > 0
	planner = Sfp::Planner.new
	puts planner.solve({:file => ARGV[0], :pretty_json => true})

else
	puts "Usage: #{$0} [options] <sfp-file>

options:
   <none>        parse file and solve the planning task
   -p            parse file and print it in JSON format
   --exec-ruby   parse file, solve the planning task, and
                 execute the plan with Sfp::RubyExecutor
   --exec-bash   parse file, solve the planning task, and
                 execute the plan with Sfp::BashExecutor

"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sfp-0.1.3 bin/sfp