Class: SdrClient::CLI
- Inherits:
-
Thor
- Object
- Thor
- SdrClient::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/sdr_client/cli.rb
Overview
The SDR command-line interface
Class Method Summary collapse
- .default_url ⇒ Object
-
.exit_on_failure? ⇒ Boolean
Make sure Thor commands preserve exit statuses.
-
.handle_no_command_error(command) ⇒ Object
Print out help and exit with error code if command not found.
Instance Method Summary collapse
- #deposit(*files) ⇒ Object
- #get(druid) ⇒ Object
- #login ⇒ Object
- #register(*files) ⇒ Object
- #update(druid) ⇒ Object
- #version ⇒ Object
Class Method Details
.default_url ⇒ Object
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: [:url], logger: Logger.new($stderr)) end end |
#login ⇒ Object
42 43 44 |
# File 'lib/sdr_client/cli.rb', line 42 def login authentication_proxy_url ? login_via_proxy : login_via_credentials 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, **) poll_for_job_complete(job_id: job_id, url: [:url]) end end |
#version ⇒ Object
47 48 49 |
# File 'lib/sdr_client/cli.rb', line 47 def version say VERSION end |