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
# File 'lib/convert_theme/cli.rb', line 5

def self.execute(stdout, arguments=[])
  options = {}
  options[:template_root] = arguments.shift
  path_to_rails_app = 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 [options]\n\n      Options are:\n    BANNER\n    opts.separator \"\"\n    opts.on(\"--content_id=CONTENT_ID\", String,\n            \"DOM id for the main DOM element for the <%= yield %>.\",\n            \"Default: content\") { |arg| options[:content_id] = arg }\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(\"-h\", \"--help\",\n            \"Show this help message.\") { stdout.puts opts; exit }\n    opts.parse!(arguments)\n  end\n  unless options[:template_root] && path_to_rails_app\n    stdout.puts parser; exit\n  end\n  ConvertTheme.new(options).apply_to(path_to_rails_app)\nend\n".gsub(/^          /,'')