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 <<-MESSAGE
Commands are:
send:    Send the email to the specified recipients.
preview: Open the HTML for the email in your browser.
clear:   Remove temporary preview files.

Example Usage:
$ lipwig send email.markdown
$ lipwig preview email.markdown

Sending emails requires LIPWIG_POSTMARK_API_KEY to be set. Recipients are
whatever is set in the email's frontmatter, but can be overridden by
LIPWIG_RECIPIENTS.
    MESSAGE
  end
end