Class: Lipwig::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, source) ⇒ CLI

Returns a new instance of CLI.



6
7
8
# File 'lib/lipwig/cli.rb', line 6

def initialize(command, source)
  @command, @source = command, source
end

Class Method Details

.call(command = '', source = '') ⇒ Object



2
3
4
# File 'lib/lipwig/cli.rb', line 2

def self.call(command = '', source = '')
  new(command, source).call
end

Instance Method Details

#callObject



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

def call
  case command
  when 'send'
    Lipwig::Senders.call email
  when 'preview'
    Lipwig::Preview.call email
  when 'clear'
    Dir['lipwig-preview-*.html'].each { |file| File.delete file }
  else
    puts "Unknown command #{command}." unless command == 'help'
    puts "Commands are:\nsend:    Send the email to the specified recipients.\npreview: Open the HTML for the email in your browser.\nclear:   Remove temporary preview files.\n\nExample Usage:\n$ lipwig send email.markdown\n$ lipwig preview email.markdown\n\nSending emails requires LIPWIG_POSTMARK_API_KEY to be set. Recipients are\nwhatever is set in the email's frontmatter, but can be overridden by\nLIPWIG_RECIPIENTS.\n    MESSAGE\n  end\nend\n"