Sha256: 5dff73455f32e0a0639d1b66bffc55e2a3698304b6b7be31f4045001fb7a252d
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.7 (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.7 | bin/sfp |