Class: Pushbullet_CLI::Push

Inherits:
Thor
  • Object
show all
Defined in:
lib/pb/cli/push.rb

Instance Method Summary collapse

Instance Method Details

#create(message = "") ⇒ Object

method_option :person, :aliases => “-p”, :desc => “Delete the file after parsing it”



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pb/cli/push.rb', line 15

def create( message = "" )
  if File.pipe?( STDIN ) || File.select( [STDIN], [], [], 0 ) != nil then
    message = STDIN.readlines().join( "" )
  end

  url = "https://api.pushbullet.com/v2/pushes"
  token = Utils::get_token( options )

  unless message.empty?
    args = Utils::get_push_args( options )
    args['body'] = message
    Utils::send( url, token, "post", args )
  else
    puts "Nothing to do."
  end
end

#listObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pb/cli/push.rb', line 35

def list
  url = "https://api.pushbullet.com/v2/pushes?active=true"
  token = Utils::get_token( options )
  cols = [ 'iden', 'type', 'title', 'created' ]

  unless options[:fields].nil?
    unless options[:fields].empty?
      cols = options[:fields].split( /\s*,\s*/ )
    end
  end

  result = Utils::send( url, token, "get" )
  Utils::print( {
    :format => options[:format],
    :cols => cols,
    :rows => result['pushes'],
  } )
end