pb-cli 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd953098ed7f1914d212fd03f90b2777466d53c1
4
- data.tar.gz: 4c3732232b90d0cd7c5e0d3fcf676b91e35a4e78
3
+ metadata.gz: 3cf14545e96206baca46c7f609151005d0a363f4
4
+ data.tar.gz: 4527730687bac7a82ef6f916240ed1f5ec1378ce
5
5
  SHA512:
6
- metadata.gz: 85aa6d0fc1cc40ea4d281246a5b4002a03cee5e2f5a25dc834dd2d03c4086a2dbd2d83d3d241edecb3396873240b3601eed93abcaefab01a7c4aad7da2ee8a0f
7
- data.tar.gz: 7c044fb66bfb8d7668eb091a24c2e01dfe88b4956f624485ea2c8f9656180f07b07469e4ecc1207ec5da8a0ebf430af9cdfb87e8e8aeb6d349790a38b230e923
6
+ metadata.gz: 14cf88750591bd8c6ae8fe1d223d134f0a6778eaad5db462b94d93e17ed18b3ca506b547e1bad0b348eda293ce039ddbd578901efb4c64c00c958b6d76558251
7
+ data.tar.gz: 5e9e59dba592122513cfd88c515ef680b6653f94611b69e96d27ac2ef22c2f758c4997c4a233b54d760ad75a8a7638175e4867e7feefc645ae2cbaae7b0839e7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pb-cli (0.2.1)
4
+ pb-cli (0.3.0)
5
5
  rest-client (~> 1.8)
6
6
  terminal-table (~> 1.5)
7
7
  thor (~> 0.19)
data/README.md CHANGED
@@ -27,13 +27,13 @@ To access the Pushbullet API you'll need an access token so the server knows who
27
27
  Send notification.
28
28
 
29
29
  ```
30
- $ pb push <MESSAGE> [--title <TITLE>]
30
+ $ pb push create <MESSAGE> [--title <TITLE>]
31
31
  ```
32
32
 
33
33
  Or send notification from STDIN.
34
34
 
35
35
  ```
36
- $ ls -al | pb push
36
+ $ ls -al | pb push create
37
37
  ```
38
38
 
39
39
  See also `pb help`.
@@ -49,7 +49,7 @@ $ bundle install --path vendor/bundle
49
49
  ### Running automated tests
50
50
 
51
51
  ```
52
- $ bundle exec rspec
52
+ $ access_token=<ACCESS_TOKEN> bundle exec rspec
53
53
  ```
54
54
 
55
55
  ## Contributing
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ # vim: ft=ruby expandtab shiftwidth=2 tabstop=2
3
+
4
+ require "thor"
5
+
6
+ module Pushbullet_CLI
7
+ class Push < Thor
8
+ class_option :token, :desc => "Access token"
9
+
10
+ desc "create <MESSAGE>", "Send a push to devices or another persons."
11
+ method_option :title, :desc => "Title of the notification."
12
+ method_option :device, :desc => "Iden of the target device to push."
13
+ # method_option :person, :aliases => "-p", :desc => "Delete the file after parsing it"
14
+ def create( message = "" )
15
+ if File.pipe?( STDIN ) || File.select( [STDIN], [], [], 0 ) != nil then
16
+ message = STDIN.readlines().join( "" )
17
+ end
18
+
19
+ url = "https://api.pushbullet.com/v2/pushes"
20
+ token = Utils::get_token( options )
21
+
22
+ unless message.empty?
23
+ args = {
24
+ "type" => "note",
25
+ "body" => message,
26
+ "title" => ( options[:title] ? options[:title] : "" )
27
+ }
28
+
29
+ unless options[:device].nil?
30
+ unless options[:device].empty?
31
+ args['device_iden'] = options[:device]
32
+ end
33
+ end
34
+
35
+ Utils::send( url, token, "post", args )
36
+ else
37
+ puts "Nothing to do."
38
+ end
39
+ end
40
+
41
+ end
42
+ end
@@ -36,7 +36,7 @@ module Pushbullet_CLI
36
36
  unless token.empty?
37
37
  return token
38
38
  else
39
- puts "Please initialize an Access Token with `pb init <ACCESS-TOKEN>`."
39
+ $stderr.puts "Please initialize an Access Token with `pb init <ACCESS-TOKEN>` or run command with `--token=<ACCESS-TOKEN>`."
40
40
  exit 1
41
41
  end
42
42
  end
@@ -2,5 +2,5 @@
2
2
  # vim: ft=ruby expandtab shiftwidth=2 tabstop=2
3
3
 
4
4
  module Pushbullet_CLI
5
- VERSION = "0.2.1"
5
+ VERSION = "0.3.0"
6
6
  end
data/lib/pb/cli.rb CHANGED
@@ -2,46 +2,18 @@
2
2
  # vim: ft=ruby expandtab shiftwidth=2 tabstop=2
3
3
 
4
4
  require "pb/cli/version"
5
- require "pb/cli/util"
5
+ require "pb/cli/utils"
6
6
  require "pb/cli/device"
7
+ require "pb/cli/push"
7
8
  require "thor"
8
9
  require "rest-client"
9
10
  require "yaml"
10
11
 
11
12
  module Pushbullet_CLI
12
13
  class Command < Thor
13
- class_option :token, :desc => "Access token"
14
+ class_option :token, :desc => "Your access token for Pushbullet API."
14
15
 
15
- desc "push <MESSAGE>", "Send a push to devices or another persons."
16
- method_option :title, :desc => "Title of the notification."
17
- method_option :device, :desc => "Iden of the target device to push."
18
- # method_option :person, :aliases => "-p", :desc => "Delete the file after parsing it"
19
- def push( message = "" )
20
- if File.pipe?( STDIN ) || File.select( [STDIN], [], [], 0 ) != nil then
21
- message = STDIN.readlines().join( "" )
22
- end
23
-
24
- url = "https://api.pushbullet.com/v2/pushes"
25
- token = Utils::get_token( options )
26
-
27
- if message
28
- args = {
29
- "type" => "note",
30
- "body" => message,
31
- "title" => ( options[:title] ? options[:title] : "" )
32
- }
33
-
34
- if options[:device]
35
- args['device_iden'] = options[:device]
36
- end
37
-
38
- Utils::send( url, token, "post", args )
39
- else
40
- puts "Nothing to do."
41
- end
42
- end
43
-
44
- desc "init <ACCESS-TOKEN>", "Initialize pb-cli"
16
+ desc "init <ACCESS-TOKEN>", "Writes access token into your config file."
45
17
  def init( access_token )
46
18
  unless Dir.exist? File.join( ENV["HOME"], '.pb-cli' )
47
19
  FileUtils.mkdir( File.join( ENV["HOME"], '.pb-cli' ) );
@@ -54,5 +26,9 @@ module Pushbullet_CLI
54
26
 
55
27
  desc "device <SUBCOMMAND>", "Manage devices."
56
28
  subcommand "device", Device
29
+
30
+ desc "push <SUBCOMMAND>", "Send or manage notifications."
31
+ subcommand "push", Push
32
+
57
33
  end # end class Command
58
34
  end # end module Pushbullet_CLi
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pb-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miya0001
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,7 +100,8 @@ files:
100
100
  - exe/pb
101
101
  - lib/pb/cli.rb
102
102
  - lib/pb/cli/device.rb
103
- - lib/pb/cli/util.rb
103
+ - lib/pb/cli/push.rb
104
+ - lib/pb/cli/utils.rb
104
105
  - lib/pb/cli/version.rb
105
106
  - pb-cli.gemspec
106
107
  homepage: https://github.com/miya0001/pb-cli