Sha256: 000ef126a18502cdadda18984ecdc283793e3a7c4f5005e20c42894b42168885

Contents?: true

Size: 863 Bytes

Versions: 17

Compression:

Stored size: 863 Bytes

Contents

#!/usr/bin/env ruby

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

opts = Trollop::options do
	version "sfp " + File.read("#{dir}/../VERSION").sub(/\n/, '')  + " (c) 2013 Herry"
	banner <<-EOS
Parse a SFP file and print the result in JSON format.

Usage:
       sfp <file>
EOS

	opt :pretty, "Print the result in pretty JSON format.", :short => '-r'
	opt :yaml, "Print the result in YAML format.", :short => '-y'
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 != ''
	if opts[:yaml]
		puts YAML.dump(JSON[parse(filepath).to_json({:pretty => opts[:pretty]})])
	else
		puts parse(filepath).to_json({:pretty => opts[:pretty]})
	end
else
	Trollop::help
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sfp-0.4.6 bin/sfp
sfp-0.4.4 bin/sfp
sfp-0.4.2 bin/sfp
sfp-0.4.1 bin/sfp
sfp-0.3.22 bin/sfp
sfp-0.3.21 bin/sfp
sfp-0.3.19 bin/sfp
sfp-0.3.18 bin/sfp
sfp-0.3.17 bin/sfp
sfp-0.3.16 bin/sfp
sfp-0.3.15 bin/sfp
sfp-0.3.14 bin/sfp
sfp-0.3.13 bin/sfp
sfp-0.3.12 bin/sfp
sfp-0.3.11 bin/sfp
sfp-0.3.10 bin/sfp
sfp-0.3.9 bin/sfp