delicious-cli 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/delicious-cli.rb +38 -22
  2. metadata +5 -5
data/lib/delicious-cli.rb CHANGED
@@ -25,16 +25,6 @@ end
25
25
 
26
26
  #################################################################
27
27
 
28
- def search(words)
29
- matches = Database.find(words)
30
- matches.each { |match| display(match, words) }
31
- end
32
-
33
- def last(n)
34
- posts = Database.last(n)
35
- posts.each { |post| display(post) }
36
- end
37
-
38
28
  def sync
39
29
  puts "* Synchronizing database..."
40
30
  Database.sync
@@ -110,6 +100,14 @@ def main
110
100
  opts.separator " "
111
101
  opts.separator "Specific options:"
112
102
 
103
+ opts.on("-c", "--config", "(Re)configure login info (set your delicious username/password)") do |opt|
104
+ options.config = true
105
+ end
106
+
107
+ opts.on("-t", "--test-auth", "Test that authentication info works") do |opt|
108
+ options.test_auth = true
109
+ end
110
+
113
111
  opts.on("-s", "--sync", "Synchronize links") do |opt|
114
112
  options.sync = true
115
113
  end
@@ -117,7 +115,11 @@ def main
117
115
  opts.on("-r", "--redownload", "Erase database and redownload all links") do |opt|
118
116
  options.redownload = true
119
117
  end
120
-
118
+
119
+ opts.on("-a", "--all", "Show all links.") do |opt|
120
+ options.list = 0
121
+ end
122
+
121
123
  opts.on("-l", "--list [num]", "List the last [num] links (default 5, 0 for all)") do |opt|
122
124
  if opt
123
125
  options.list = opt.to_i
@@ -126,14 +128,10 @@ def main
126
128
  end
127
129
  end
128
130
 
129
- opts.on("-c", "--config", "Configure login info (set delicious username/password)") do |opt|
130
- options.config = true
131
- end
132
-
133
- opts.on("-t", "--test-auth", "Test that authentication info works") do |opt|
134
- options.test_auth = true
131
+ opts.on("-j", "--json", "Output results as (pretty) JSON.") do |opt|
132
+ options.json = true
135
133
  end
136
-
134
+
137
135
  opts.on("-d", "--debug", "Debug info") do |opt|
138
136
  options.debug = true
139
137
  end
@@ -172,11 +170,29 @@ def main
172
170
  redownload
173
171
  elsif options.sync
174
172
  sync
175
- elsif options.list
176
- last(options.list)
177
173
  else
178
- exit 1 unless ARGV.size > 0
179
- search(ARGV)
174
+
175
+ # get posts
176
+ if options.list
177
+ posts = Database.last(options.list)
178
+ else
179
+ words = ARGV
180
+ exit 1 unless words.size > 0
181
+ posts = Database.find(words)
182
+ end
183
+
184
+
185
+ if options.json
186
+ require 'json'
187
+ puts JSON.pretty_generate(posts)
188
+ else
189
+ if words
190
+ posts.each { |match| display(match, words) }
191
+ else
192
+ posts.each { |post| display(post) }
193
+ end
194
+ end
195
+
180
196
  end
181
197
 
182
198
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delicious-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-29 00:00:00.000000000 Z
12
+ date: 2011-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &73716350 !ruby/object:Gem::Requirement
16
+ requirement: &68564890 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *73716350
24
+ version_requirements: *68564890
25
25
  description: A commandline tool which lets you download all your delicious.com links
26
26
  and search them (with pretty color-coded results).
27
27
  email: chris@ill-logic.com
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 1.8.6
73
+ rubygems_version: 1.8.10
74
74
  signing_key:
75
75
  specification_version: 3
76
76
  summary: Delicious.com commandline interface