Sha256: 1c72e2b9843a0cfadbcb904c86cd048d016aa6625caac870d1b1f9f89f08469e
Contents?: true
Size: 821 Bytes
Versions: 1
Compression:
Stored size: 821 Bytes
Contents
#!/usr/bin/env ruby libdir = File.expand_path(File.dirname(__FILE__)) require "#{libdir}/../lib/sfp" require 'yaml' opts = Trollop::options do version "sfp 0.3.5 (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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sfp-0.3.6 | bin/sfp |