Class: Pushbullet_CLI::Command
- Inherits:
-
Thor
- Object
- Thor
- Pushbullet_CLI::Command
- Defined in:
- lib/pb/cli.rb
Instance Method Summary collapse
- #init(access_token) ⇒ Object
-
#push(message = "") ⇒ Object
method_option :person, :aliases => “-p”, :desc => “Delete the file after parsing it”.
Instance Method Details
#init(access_token) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/pb/cli.rb', line 45 def init( access_token ) unless Dir.exist? File.join( ENV["HOME"], '.pb-cli' ) FileUtils.mkdir( File.join( ENV["HOME"], '.pb-cli' ) ); end File.open( File.join( ENV["HOME"], '.pb-cli', 'config.yml' ), "w" ) do | file | file.write( "access_token: " + access_token ) end FileUtils.chmod( 0600, File.join( ENV["HOME"], '.pb-cli', 'config.yml' ) ) end |
#push(message = "") ⇒ Object
method_option :person, :aliases => “-p”, :desc => “Delete the file after parsing it”
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pb/cli.rb', line 19 def push( = "" ) 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( ) if args = { "type" => "note", "body" => , "title" => ( [:title] ? [:title] : "" ) } if [:device] args['device_iden'] = [:device] end Utils::send( url, token, "post", args ) else puts "Nothing to do." end end |