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(help = "") ⇒ Object
Instance Method Details
#create(message = "") ⇒ Object
method_option :person, :aliases => “-p”, :desc => “Delete the file after parsing it”
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pb/cli/push.rb', line 16 def create( = "" ) if "help" == invoke( :help, [ "create" ] ); exit 0 end 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(help = "") ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pb/cli/push.rb', line 41 def list( help = "" ) unless help.empty? if "help" == help invoke( :help, [ "list" ] ); exit 0 else self.class.handle_argument_error exit 1 end end 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 |