Class: SdrClient::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/sdr_client/cli.rb

Overview

The SDR command-line interface

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_urlObject



26
27
28
# File 'lib/sdr_client/cli.rb', line 26

def self.default_url
  'https://sdr-api-prod.stanford.edu'
end

.exit_on_failure?Boolean

Make sure Thor commands preserve exit statuses



14
15
16
# File 'lib/sdr_client/cli.rb', line 14

def self.exit_on_failure?
  true
end

.handle_no_command_error(command) ⇒ Object

Print out help and exit with error code if command not found



19
20
21
22
23
24
# File 'lib/sdr_client/cli.rb', line 19

def self.handle_no_command_error(command)
  puts "Command '#{command}' not found, displaying help:"
  puts
  puts help
  exit(1)
end

Instance Method Details

#deposit(*files) ⇒ Object



91
92
93
# File 'lib/sdr_client/cli.rb', line 91

def deposit(*files)
  register_or_deposit(files: files, accession: true)
end

#get(druid) ⇒ Object



35
36
37
38
39
# File 'lib/sdr_client/cli.rb', line 35

def get(druid)
  rescue_expected_exceptions do
    say Find.run(druid, url: options[:url], logger: Logger.new($stderr))
  end
end

#loginObject



42
43
44
# File 'lib/sdr_client/cli.rb', line 42

def 
  authentication_proxy_url ?  : 
end

#register(*files) ⇒ Object



113
114
115
# File 'lib/sdr_client/cli.rb', line 113

def register(*files)
  register_or_deposit(files: files, accession: false)
end

#update(druid) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/sdr_client/cli.rb', line 65

def update(druid)
  rescue_expected_exceptions do
    validate_druid!(druid)
    job_id = Update.run(druid, **options)
    poll_for_job_complete(job_id: job_id, url: options[:url])
  end
end

#versionObject



47
48
49
# File 'lib/sdr_client/cli.rb', line 47

def version
  say VERSION
end