Use pretty mode by default in CLI

This commit is contained in:
Takashi Kokubun 2015-10-24 02:16:35 +09:00
parent 473c55f7ba
commit 0b971624e8
1 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,8 @@ require 'thor'
module Hamlit
class CLI < Thor
class_option :style, type: :string, aliases: ['-t'], default: 'pretty'
desc 'render HAML', 'Render haml template'
def render(file)
code = generate_code(file)
@ -23,7 +25,7 @@ module Hamlit
def generate_code(file)
template = File.read(file)
Hamlit::Engine.new.call(template)
Hamlit::Engine.new(engine_options).call(template)
end
def generate_ast(file)
@ -31,6 +33,10 @@ module Hamlit
Hamlit::Parser.new.call(template)
end
def engine_options
{ pretty: options['style'] == 'pretty' }
end
# Flexible default_task, compatible with haml's CLI
def method_missing(*args)
return super(*args) if args.length > 1