Class: Pushbullet_CLI::Push
- Inherits:
-
Thor
- Object
- Thor
- Pushbullet_CLI::Push
- Defined in:
- lib/pb/cli/push.rb
Instance Method Summary collapse
-
#create(message = "") ⇒ Object
method_option :person, :aliases => “-p”, :desc => “Delete the file after parsing it”.
- #list ⇒ Object
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( = "" ) if File.pipe?( STDIN ) || File.select( [STDIN], [], [], 0 ) != nil then = STDIN.readlines().join( "" ) end url = "https://api.pushbullet.com/v2/pushes" token = Utils::get_token( ) unless .empty? args = Utils::get_push_args( ) args['body'] = Utils::send( url, token, "post", args ) else puts "Nothing to do." end end |
#list ⇒ Object
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( ) cols = [ 'iden', 'type', 'title', 'created' ] unless [:fields].nil? unless [:fields].empty? cols = [:fields].split( /\s*,\s*/ ) end end result = Utils::send( url, token, "get" ) Utils::print( { :format => [:format], :cols => cols, :rows => result['pushes'], } ) end |