Use pretty mode by default in CLI
This commit is contained in:
parent
473c55f7ba
commit
0b971624e8
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue