Module: Hamler

Defined in:
lib/hamler.rb,
lib/hamler/version.rb

Defined Under Namespace

Classes: Hamler

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.with(argv) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/hamler.rb', line 102

def self.with( argv )
  options = {
    :haml_available => available?("haml"),
    :sass_available => available?("sass"),
    :coffeescript_available \
                    => available?("coffee-script"),
    :output_folder  => false,
    :input_folder   => false,
    :dry_run        => false,
    :purge          => false,
  }
  o = OptionParser.new do |opts|
    opts.banner = "Usage: hamler [options]"
    opts.separator ''
    opts.separator 'options:'

    opts.on('-i FOLDER',
            '--input-folder FOLDER',
            'folder of source files, MUST be given') \
      {|val| options[ :input_folder ] = val }

    opts.on('-o', '--output-folder FOLDER', 'folder for output files, default to be the same with input-folder') \
      {|val| options[ :output_folder ] = val }
    opts.on('-d', '--dry-run', 'dry run without actually modify files') \
      {|val| options[ :dry_run ] = val }

    opts.on('-p', '--purge', 'purge filenames that would be generated') \
      {|val| options[ :purge ] = val }

    opts.on_tail('-h', '--help', 'show this usage') {puts opts}
  end
  o.parse( argv )

  if options[ :input_folder ]
    Hamler.new([],options).root_task
  else
    puts o
  end
end