Sha256: 8c044df5bb520393355f30f6d2bb569c1d4e56efcce52ebc082facc27e35cdaa

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby

dir = File.expand_path(File.dirname(__FILE__))
current_version = File.read(File.join(File.dirname(__FILE__), '../VERSION')).sub(/\n/, '')
require "#{dir}/../lib/sfplanner"

opts = Trollop::options do
	version "sfplanner " + current_version + " (c) 2013 Herry"
	banner <<-EOS
Solve a planning task specified in SFP language, and print the plan (if found) in JSON format.

Usage:
       sfplanner [options] <file>

where [options] are:
EOS

	opt :parallel, "Generate a parallel (partial-order) plan, instead of sequential."
	opt :json_input, "Input is in JSON format"
	opt :pretty, "Print the plan in pretty JSON format"
end

def parse(filepath)
	home_dir = File.expand_path(File.dirname(filepath))
	parser = Sfp::Parser.new({:home_dir => home_dir})
	parser.parse(File.read(filepath))
	parser
end

filepath = ARGV[0].to_s

if filepath != ''
	planner = Sfp::Planner.new
	options = {:file => ARGV[0],
	           :json => !opts[:pretty],
	           :pretty_json => opts[:pretty],
	           :parallel => opts[:parallel]}
	if opts[:json_input]
		options[:input_json] = true
		puts planner.solve(options)
	else
		puts planner.solve(options)
	end
else
	Trollop::help
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sfplanner-0.1.3 bin/sfplanner
sfplanner-0.1.2 bin/sfplanner