lard 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/lard +24 -61
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f852d0bc375caa5f0e0fb5eba5d1072bfaacf1b40effe0cb94b68739b53e070
4
- data.tar.gz: '085514e8aa946f7e993bc6f414324b0b68dfbe57970373879a9700c1a8b804d6'
3
+ metadata.gz: 87f51cb7f7af091dc328b99971eec87a2de0220683644d7c4f18581c0b0748b4
4
+ data.tar.gz: 21c8a6e0ba001bf3cccdbb6e5630c6b49cd31708e2b59b95d84f358360d663f5
5
5
  SHA512:
6
- metadata.gz: a0976e09f1788a462d4edafc82710c5a98791b2c43acf66d98da85deb79baf29933e56c28e537f3676d8af32fd4e604d030ee09ad7a4b8d5593afb19b0413464
7
- data.tar.gz: ee4995a6e20bd35c07a15c1fbf2d0c253cfef7b93984e935bd518339ea02069bb2e06f8879ed242138d68d2da2d41a8e73ed855309de990772ebeac2cb064d5b
6
+ metadata.gz: bf3a767116cfded14043638e2495ca3d05d18a96c1d6b218328d0b2838ccd4d7835b27b3c513c5cccfacd0db4cacaea59a49123a0d9dac8b0c58369c2ab00e2a
7
+ data.tar.gz: 71e4d72b042dd61507be61234397d36ec9b0725b99509811a42e847dfa80f6e48a47f61f14730c90848cb8db241dc3ee6cb15ca96afa0617c89a8e679793793a
data/bin/lard CHANGED
@@ -26,7 +26,6 @@ $folders = []
26
26
 
27
27
  module LardHTTP
28
28
  def get(endpoint, params = nil)
29
- puts $authenticated
30
29
  raise "You're not logged in! Run 'lard login' first." unless $authenticated
31
30
  query = { query: params }
32
31
  opts = $options.merge query
@@ -108,13 +107,13 @@ module LardHTTP
108
107
  puts " #{bookmark[:description]}" if bookmark[:description]
109
108
  puts " #{bookmark[:url]}"
110
109
 
111
- unless bookmark[:tags].empty?
110
+ unless bookmark[:tags] == nil && bookmark[:tags].empty?
112
111
  print " "
113
112
  bookmark[:tags].each do |tag|
114
113
  print Paint["##{tag[:name]}", tag[:color]]
115
114
  print " "
116
115
  end
117
- puts " "
116
+ puts ""
118
117
  end
119
118
  end
120
119
 
@@ -123,69 +122,11 @@ module LardHTTP
123
122
  end
124
123
  end
125
124
 
126
- class Bookmark < Thor
127
- include LardHTTP
128
- include HTTParty
129
- maintain_method_across_redirects
130
-
131
- desc 'new <FOLDER> <TITLE> <LINK> [tags...]', 'Creates a new bookmark'
132
- option :description, :aliases => :d
133
- def new(folder, title, link, *tags)
134
- f = get_folder_by_name folder
135
- raise "No such folder" unless f
136
- parent = f[:id]
137
-
138
- res = post 'links/add', {
139
- "title" => title,
140
- "url" => link,
141
- "parent" => parent,
142
- "description" => options[:description],
143
- "tags" => tags
144
- }
145
- unless res[:error]
146
- print_bookmark res
147
- else
148
- # TODO: Test this
149
- raise "Unable to add bookmark"
150
- end
151
- end
152
-
153
- # Note that this uses the same endpoint as 'new'
154
- # simply for the purpose of looking up bookmarks
155
- # by the link and not proprietary ID
156
- #desc 'edit <LINK> [tags...]', 'Edits an existing bookmark'
157
- #option :title, :aliases => :t
158
- #option :folder, :aliases => :f
159
- #option :description, :aliases => :d
160
- #def edit(link, *tags)
161
- # f = get_folder_by_name options[:folder]
162
- # raise "No such folder" unless f
163
- # parent = f[:id]
164
-
165
- # res = post 'links/add', {
166
- # "title" => options[:title],
167
- # "url" => link,
168
- # "parent" => parent,
169
- # "description" => options[:description],
170
- # "tags" => tags
171
- # }
172
- # unless res[:error]
173
- # print_bookmark res
174
- # else
175
- # # TODO: Test this
176
- # raise "Unable to add bookmark"
177
- # end
178
- #end
179
- end
180
-
181
125
  class Lard < Thor
182
126
  include LardHTTP
183
127
  include HTTParty
184
128
  maintain_method_across_redirects
185
129
 
186
- desc "bookmark <COMMAND>", "Manage individual bookmarks"
187
- subcommand "bookmark", Bookmark
188
-
189
130
  desc 'user', 'Prints information about the logged-in user'
190
131
  def user
191
132
  puts get('user')
@@ -251,6 +192,28 @@ class Lard < Thor
251
192
  end
252
193
  end
253
194
  end
195
+
196
+ desc 'bookmark <FOLDER> <TITLE> <LINK> [tags...]', 'Creates or edits a bookmark'
197
+ option :description, :aliases => :d
198
+ def bookmark(folder, title, link, *tags)
199
+ f = get_folder_by_name folder
200
+ raise "No such folder" unless f
201
+ parent = f[:id]
202
+
203
+ res = post 'links/add', {
204
+ "title" => title,
205
+ "url" => link,
206
+ "parent" => parent,
207
+ "description" => options[:description],
208
+ "tags" => tags
209
+ }
210
+ unless res[:error]
211
+ print_bookmark res
212
+ else
213
+ # TODO: Test this
214
+ raise "Unable to add bookmark"
215
+ end
216
+ end
254
217
  end
255
218
 
256
219
  Lard.start(ARGV)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - hawkins