Class: ConvertTheme::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/convert_theme/cli.rb

Class Method Summary collapse

Class Method Details

.execute(stdout, arguments = []) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/convert_theme/cli.rb', line 5

def self.execute(stdout, arguments=[])
  options = {}
  options[:template_root] = arguments.shift
  options[:rails_root]    = arguments.shift
  options[:content_id]    = arguments.shift
  parser = OptionParser.new do |opts|
    opts.banner = "      Use any HTML template as a theme generator for your Rails app.\n\n      Usage: \#{File.basename($0)} path/to/template path/to/rails_app content_id [options]\n\n      Options are:\n    BANNER\n    opts.separator \"\"\n    opts.on(\"--haml\",\n            \"Generate HAML templates.\") { |arg| options[:template_type] = 'haml' }\n    opts.on(\"--index_path=index.html\", String,\n            \"HTML page to use for application layout.\",\n            \"Default: index.html\") { |arg| options[:index_path] = arg }\n    opts.on(\"--inside_yield=KEY_AND_CSS_PATH\", String,\n            \"Replace the inner HTML of an element with <%= yield :key %>\",\n            \"Default: nil\") do |arg|\n              options[:inside_yields] ||= {}\n              key, css_path = arg.split(/\\s*=>\\s*/)[0..1]\n              options[:inside_yields][key.strip.to_sym] = css_path.strip\n            end\n    opts.on(\"-h\", \"--help\",\n            \"Show this help message.\") { stdout.puts opts; exit }\n    opts.parse!(arguments)\n  end\n  unless options[:template_root] && options[:rails_root]\n    stdout.puts parser; exit\n  end\n  ConvertTheme.new(options).apply_to_target\nend\n".gsub(/^          /,'')