lib/buttonize/cli.rb in flurin-buttonize-0.1.2 vs lib/buttonize/cli.rb in flurin-buttonize-0.1.4

- old
+ new

@@ -1,8 +1,9 @@ require 'thor' module Buttonize + EXAMPLE_STYLE_FILE = File.join(File.dirname(__FILE__),"../../examples/default/styles.rb") class CLI < Thor desc "generate BUTTONSET", "Generates a whole bunch of buttons from a ButtonSet file" method_options :target_path => :optional, # The target where to put the generated buttons, defaults to PWD + "buttons" @@ -23,19 +24,23 @@ # Load the buttonset require buttonset raise "Are you sure #{buttonset} is a buttonset file?" if !ButtonSet.current + if !ButtonSet.current.options[:style_file] + require EXAMPLE_STYLE_FILE + end + puts "Generating buttons...." ButtonSet.current.send(:generate_buttons,options) end desc "button TEXT [OUTFILE]", "Generates a single button with TEXT on it, it sanitizes the text to generate filename" method_options :style_file => :optional, # The styleset file to load. Defaults to default built-in styles :style_set => :optional, # The styleset to use. Defaults to "default" :style => :required # The button style to use. def button(text,outfile=nil) - options = {"style_file" => File.join(File.dirname(__FILE__),"../../examples/default/styles.rb"), "style_set" => :default}.update(self.options) + options = {"style_file" => EXAMPLE_STYLE_FILE, "style_set" => :default}.update(self.options) style = get_style(options["style_file"],options["style_set"],options["style"]) Buttonize::Button.new(style).generate(text,outfile) end protected \ No newline at end of file