Module: Erbside

Extended by:
MetadataMixin
Defined in:
lib/erbside.rb,
lib/erbside/inline.rb,
lib/erbside/runner.rb,
lib/erbside/context.rb,
lib/erbside/metadata.rb,
lib/erbside/inline/js.rb,
lib/erbside/inline/cpp.rb,
lib/erbside/inline/css.rb,
lib/erbside/inline/bash.rb,
lib/erbside/inline/ruby.rb,
lib/erbside/inline/sgml.rb

Defined Under Namespace

Modules: MetadataMixin Classes: Bash, CSS, Context, Cpp, Inline, Javascript, Metadata, Ruby, Runner, SGML

Class Method Summary collapse

Methods included from MetadataMixin

const_missing, metadata

Class Method Details

.cli(argv = ARGV) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/erbside.rb', line 23

def self.cli(argv=ARGV)
  require 'optparse'
  require 'erbside/runner'

  options = {:resources=>[]}

  usage = OptionParser.new do |use|
    use.banner = 'Usage: erbside [OPTIONS] [FILE1 FILE2 ...]'

    #use.on('--delete', 'delete templates when finished') do
    #  options[:delete] = true
    #end

    use.on('-r', '--resource FILE', 'get metadata from file') do |file|
      options[:resources] << file
    end

    use.on('-f', '--force', 'automatically make overwrites') do
      options[:force] = true
    end

    use.on('-s', '--skip', 'automatically skip overwrites') do
      options[:skip] = true
    end

    use.on('-o', '--stdout', 'dump output to stdout instead of saving') do
      options[:output] = $stdout
    end

    use.on('-t', '--trial', 'run in trial mode') do
      $TRIAL = true
    end

    use.on('--debug', 'run in debug mode') do
      $DEBUG = true
    end

    use.on_tail('-h', '--help', 'display this help information') do
      puts use
      exit
    end
  end

  usage.parse!(argv)

  files = argv

  runner = Erbside::Runner.new(files, options)

  runner.render
end