Improve script input

This commit is contained in:
Alex Kotov 2023-09-30 19:46:10 +04:00
parent 032c7c6339
commit 2c7228c0e0
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 12 additions and 7 deletions

12
test.rb
View File

@ -99,16 +99,20 @@ cmd :REGISTER_CATEGORY, :link
###################
cmd :REGISTER_FORMAT, { name: :html,
stdin: { notes: nil },
args: ['test/render.rb',
{ template: nil },
{ format: nil }] }
{ format: nil }],
stdin: ['{"notes":',
{ notes: nil },
'}'] }
cmd :REGISTER_FORMAT, { name: :json,
stdin: { notes: nil },
args: ['test/render.rb',
{ template: nil },
{ format: nil }] }
{ format: nil }],
stdin: ['{"notes":',
{ notes: nil },
'}'] }
################
# REGISTER_REF #

View File

@ -12,6 +12,7 @@ def template(filename)
end.freeze
end
puts template("#{ARGV[0]}.#{ARGV[1]}.erb").result_with_hash(
notes: JSON.parse($stdin.read),
).strip
name = "#{ARGV[0]}.#{ARGV[1]}.erb".freeze
vars = JSON.parse($stdin.read).freeze
puts template(name).result_with_hash(vars).strip