droxi 0.4.1 → 0.5.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: e18e4d87aac63a2329521ad3914056e04e0050b4
4
- data.tar.gz: da3104c02ce7a5c2ea86d68f4800563e7acc5d37
3
+ metadata.gz: 7e6d4d129c264dd4d931b1b41244d98c4116a458
4
+ data.tar.gz: f911f97cc7ebb970dd3073595da5bb1adefec5b8
5
5
  SHA512:
6
- metadata.gz: cbf92717523c05adac49d3b7f925bdfea903543697325d6b6468da7ca419e4bf59ee7fb575ab6c27c6fec593ccc711b9567f2eac3b503e2237e1d27292f748b5
7
- data.tar.gz: 3442fecd04eb87b3c3afe40086ce4096f459fec58b3b7902426ea9d5c901e998f99998fe67054d32741edbd09c318d39cd2077f2a6fba5b7ead48de50d9adc9e
6
+ metadata.gz: e51bcc3b49d0d5c2c3307e175bc5b9ac10d3b18399009896fa85bd7d17a5a01ecacbff36e0aab07b36198baafa9cd7b6453766ff941c8a1a72e92269282491d7
7
+ data.tar.gz: b87e9923bedb52bb3893c75542d571af9529eacc4dc61655b7ad80ab5650de1badefd42a86fe6e52f511b4abb4a51a28f01a3c8939bf19f0e0049f035f534290
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2015 Brandon Mulcahy
1
+ Copyright (c) 2014-2016 Brandon Mulcahy
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'droxi'
3
3
  s.version = IO.read('lib/droxi.rb')[/VERSION = '(.+)'/, 1]
4
- s.date = '2015-06-04'
4
+ s.date = '2016-12-23'
5
5
  s.summary = 'An ftp-like command-line interface to Dropbox'
6
6
  s.description = "A command-line Dropbox interface based on GNU coreutils, \
7
7
  GNU ftp, and lftp. Features include smart tab completion, \
@@ -17,7 +17,7 @@ require_relative 'droxi/text'
17
17
  # Command-line Dropbox client module.
18
18
  module Droxi
19
19
  # Version number of the program.
20
- VERSION = '0.4.1'
20
+ VERSION = '0.5.0'
21
21
 
22
22
  # Message to display when invoked with the --help option.
23
23
  HELP_TEXT = [
@@ -47,9 +47,11 @@ module Droxi
47
47
  end
48
48
  rescue DropboxAuthError => error
49
49
  warn error
50
+ state.exit_status = 1
50
51
  Settings.delete(:access_token)
51
52
  ensure
52
53
  Settings.save
54
+ exit state.exit_status
53
55
  end
54
56
 
55
57
  private
@@ -153,6 +155,10 @@ module Droxi
153
155
 
154
156
  # Set pwd before exiting so that the oldpwd setting is saved to the pwd.
155
157
  state.pwd = '/'
158
+
159
+ # Set exit status to zero even if the last command had an error, since
160
+ # we're in interactive mode and quitting correctly.
161
+ state.exit_status = 0
156
162
  end
157
163
 
158
164
  def self.init_readline(state)
@@ -70,6 +70,7 @@ module Commands
70
70
  state.expand_patterns(args).each do |path|
71
71
  if path.is_a?(GlobError)
72
72
  warn "cat: #{path}: no such file or directory"
73
+ state.exit_status = 1
73
74
  else
74
75
  puts client.get_file(path)
75
76
  end
@@ -95,6 +96,7 @@ module Commands
95
96
  state.pwd = path
96
97
  else
97
98
  warn "cd: #{args.first}: no such directory"
99
+ state.exit_status = 1
98
100
  end
99
101
  end
100
102
  end
@@ -126,11 +128,14 @@ module Commands
126
128
  # rubocop:enable Lint/Eval
127
129
  rescue SyntaxError => error
128
130
  warn error
131
+ state.exit_status = 1
129
132
  rescue => error
130
133
  warn error.inspect
134
+ state.exit_status = 1
131
135
  end
132
136
  else
133
137
  warn 'debug: not enabled.'
138
+ state.exit_status = 1
134
139
  end
135
140
  end
136
141
  )
@@ -171,7 +176,10 @@ module Commands
171
176
  state.cache.clear
172
177
  else
173
178
  args.each do |arg|
174
- state.forget_contents(arg) { |line| warn line }
179
+ state.forget_contents(arg) do |line|
180
+ warn line
181
+ state.exit_status = 1
182
+ end
175
183
  end
176
184
  end
177
185
  end
@@ -190,6 +198,7 @@ module Commands
190
198
  state.expand_patterns(args).each do |path|
191
199
  if path.is_a?(GlobError)
192
200
  warn "get: #{path}: no such file or directory"
201
+ state.exit_status = 1
193
202
  else
194
203
  basename = File.basename(path)
195
204
  try_and_handle(DropboxError) do
@@ -203,6 +212,7 @@ module Commands
203
212
  puts "#{basename} <- #{path}"
204
213
  else
205
214
  warn "get: #{basename}: local file already exists"
215
+ state.exit_status = 1
206
216
  end
207
217
  end
208
218
  end
@@ -228,6 +238,7 @@ module Commands
228
238
  Text.wrap(cmd.description).each { |line| puts line }
229
239
  else
230
240
  warn "help: #{cmd_name}: no such command"
241
+ state.exit_status = 1
231
242
  end
232
243
  end
233
244
  end
@@ -244,6 +255,7 @@ module Commands
244
255
  path = state.resolve_path(args.first)
245
256
  if !state.metadata(path) || state.directory?(path)
246
257
  warn "history: #{args.first}: no such file"
258
+ state.exit_status = 1
247
259
  else
248
260
  try_and_handle(DropboxError) do
249
261
  client.revisions(path).each do |rev|
@@ -283,6 +295,7 @@ module Commands
283
295
  Dir.chdir(path)
284
296
  else
285
297
  warn "lcd: #{args.first}: no such directory"
298
+ state.exit_status = 1
286
299
  end
287
300
  end
288
301
  )
@@ -303,6 +316,7 @@ module Commands
303
316
  state.expand_patterns(args, true).each do |path|
304
317
  if path.is_a?(GlobError)
305
318
  warn "ls: #{path}: no such file or directory"
319
+ state.exit_status = 1
306
320
  else
307
321
  type = state.directory?(path) ? dirs : files
308
322
  type << path
@@ -336,6 +350,7 @@ module Commands
336
350
  state.expand_patterns(args).each do |path|
337
351
  if path.is_a?(GlobError)
338
352
  warn "media: #{path}: no such file or directory"
353
+ state.exit_status = 1
339
354
  else
340
355
  try_and_handle(DropboxError) do
341
356
  url = client.media(path)['url']
@@ -402,6 +417,7 @@ module Commands
402
417
  state.pwd = state.resolve_path(dest_path)
403
418
  else
404
419
  warn "put: #{dest_path}: no such directory"
420
+ state.exit_status = 1
405
421
  return
406
422
  end
407
423
  end
@@ -413,6 +429,7 @@ module Commands
413
429
  args.map! do |arg|
414
430
  array = Dir.glob(File.expand_path(arg))
415
431
  warn "put: #{arg}: no such file or directory" if array.empty?
432
+ state.exit_status = 1
416
433
  array.map { |path| path.sub(File.dirname(path), File.dirname(arg)) }
417
434
  end
418
435
  args = args.reduce(:+) unless args.empty? # avoid making args nil
@@ -424,6 +441,7 @@ module Commands
424
441
  path = File.expand_path(arg)
425
442
  if File.directory?(path)
426
443
  warn "put: #{arg}: cannot put directory"
444
+ state.exit_status = 1
427
445
  next
428
446
  end
429
447
 
@@ -466,6 +484,7 @@ module Commands
466
484
  path = state.resolve_path(args.first)
467
485
  if !state.metadata(path) || state.directory?(path)
468
486
  warn "restore: #{args.first}: no such file"
487
+ state.exit_status = 1
469
488
  else
470
489
  try_and_handle(DropboxError) do
471
490
  client.restore(path, args.last)
@@ -484,9 +503,11 @@ module Commands
484
503
  state.expand_patterns(args).each do |path|
485
504
  if path.is_a?(GlobError)
486
505
  warn "rm: #{path}: no such file or directory"
506
+ state.exit_status = 1
487
507
  else
488
508
  if state.directory?(path) && !flags.include?('-r')
489
509
  warn "rm: #{path}: is a directory"
510
+ state.exit_status = 1
490
511
  next
491
512
  end
492
513
  try_and_handle(DropboxError) do
@@ -508,14 +529,17 @@ module Commands
508
529
  state.expand_patterns(args).each do |path|
509
530
  if path.is_a?(GlobError)
510
531
  warn "rmdir: #{path}: no such file or directory"
532
+ state.exit_status = 1
511
533
  else
512
534
  unless state.directory?(path)
513
535
  warn "rmdir: #{path}: not a directory"
536
+ state.exit_status = 1
514
537
  next
515
538
  end
516
539
  contents = state.metadata(path)['contents']
517
540
  if contents && !contents.empty?
518
541
  warn "rmdir: #{path}: directory not empty"
542
+ state.exit_status = 1
519
543
  next
520
544
  end
521
545
  try_and_handle(DropboxError) do
@@ -538,6 +562,7 @@ module Commands
538
562
  path = state.resolve_path(args.first)
539
563
  unless state.directory?(path)
540
564
  warn "search: #{args.first}: no such directory"
565
+ state.exit_status = 1
541
566
  return
542
567
  end
543
568
  query = args.drop(1).join(' ')
@@ -559,6 +584,7 @@ module Commands
559
584
  state.expand_patterns(args).each do |path|
560
585
  if path.is_a?(GlobError)
561
586
  warn "share: #{path}: no such file or directory"
587
+ state.exit_status = 1
562
588
  else
563
589
  try_and_handle(DropboxError) do
564
590
  url = client.shares(path)['url']
@@ -608,9 +634,11 @@ module Commands
608
634
  command.exec(client, state, *args) { |line| puts line }
609
635
  rescue UsageError => error
610
636
  warn "Usage: #{error}"
637
+ state.exit_status = 1
611
638
  end
612
639
  else
613
640
  warn "droxi: #{command_name}: command not found"
641
+ state.exit_status = 1
614
642
  end
615
643
  end
616
644
 
@@ -651,6 +679,7 @@ module Commands
651
679
  state.expand_patterns(paths, preserve_root).map do |item|
652
680
  if item.is_a?(GlobError)
653
681
  warn "#{cmd}: #{item}: no such file or directory" if output
682
+ state.exit_status = 1
654
683
  nil
655
684
  else
656
685
  item
@@ -701,6 +730,7 @@ module Commands
701
730
  end
702
731
  else
703
732
  warn "#{cmd}: #{args.last}: no such directory"
733
+ state.exit_status = 1
704
734
  end
705
735
  end
706
736
 
@@ -30,6 +30,9 @@ class State
30
30
  # +true+ if the --debug option was given, +false+ otherwise.
31
31
  attr_accessor :debug_enabled
32
32
 
33
+ # integer.
34
+ attr_accessor :exit_status
35
+
33
36
  # Return a new application state that uses the given client. Starts at the
34
37
  # Dropbox root and with an empty cache.
35
38
  def initialize(client, interactive = true, argv = ARGV)
@@ -42,6 +45,7 @@ class State
42
45
  @pwd = '/'
43
46
  @oldpwd = Settings[:oldpwd] || '/'
44
47
  @local_oldpwd = Dir.pwd
48
+ @exit_status = 0
45
49
  end
46
50
 
47
51
  # Return a +Hash+ of the Dropbox metadata for a file, or +nil+ if the file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droxi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mulcahy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-04 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dropbox-sdk
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.4.5
81
+ rubygems_version: 2.5.2
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: An ftp-like command-line interface to Dropbox