lib/govspeak/cli.rb in govspeak-5.6.0 vs lib/govspeak/cli.rb in govspeak-5.7.0

- old
+ new

@@ -18,10 +18,11 @@ command.option("--options JSON", String, "JSON to use as options") command.option("--options-file FILENAME", String, "A file of JSON options") command.action do |args, options| input = get_input($stdin, args, options) raise "Nothing to render. Use --help for assistance" unless input + puts Govspeak::Document.new(input, govspeak_options(options)).to_html end end run! end @@ -29,23 +30,24 @@ private def get_input(stdin, args, options) return stdin.read unless stdin.tty? return read_file(options.file) if options.file + args.empty? ? nil : args.join(" ") end def read_file(file_path) path = Pathname.new(file_path).realpath File.read(path) end def govspeak_options(command_options) string = if command_options.options_file - read_file(command_options.options_file) + read_file(command_options.options_file) else - command_options.options + command_options.options end - string ? JSON.load(string) : {} + string ? JSON.parse(string) : {} end end end