class Pushnote::Cli

Attributes

configuration[R]
note[R]

Public Class Methods

new(argv) click to toggle source
# File lib/pushnote/cli.rb, line 7
def initialize(argv)
  @note = Note.new
  parse_options
end

Public Instance Methods

run() click to toggle source
# File lib/pushnote/cli.rb, line 12
def run
  note.collect_system_info
  read_note_body
  save_note
end

Private Instance Methods

parse_options() click to toggle source
# File lib/pushnote/cli.rb, line 20
def parse_options
  OptionParser.new { |opts|
    opts.banner = "Usage: pushnote [options]"
    opts.on('-t TITLE', '--title TITLE', 'Note title') do |title|
      note.title = title
    end

    opts.on('-h HOST', '--host HOST', 'Pushnote server host') do |host|
      note.set_server_host(host)
    end
 }.parse!
end
read_note_body() click to toggle source
# File lib/pushnote/cli.rb, line 33
def read_note_body
  note.body = STDIN.read.chomp
end
save_note() click to toggle source
# File lib/pushnote/cli.rb, line 37
def save_note
  note.save
end