Class: Duracloud::CLI
- Inherits:
-
Hashie::Dash
- Object
- Hashie::Dash
- Duracloud::CLI
show all
- Includes:
- Commands
- Defined in:
- lib/duracloud/cli.rb
Constant Summary
collapse
- COMMANDS =
Commands.public_instance_methods.map(&:to_s)
- USAGE =
<<-EOS
Usage: duracloud [COMMAND] [options]
Commands:
#{COMMANDS.sort.join("\n ")}
Options:
EOS
- HELP =
"Type 'duracloud -h/--help' for usage."
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Commands
#count, #download_manifest, #find, #get_storage_report, #list_content_ids, #list_items, #store, #sync, #validate
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
54
55
56
|
# File 'lib/duracloud/cli.rb', line 54
def initialize(*args)
super CommandOptions.parse(*args)
end
|
Class Method Details
.call(*args) ⇒ Object
48
49
50
51
52
|
# File 'lib/duracloud/cli.rb', line 48
def self.call(*args)
new(*args).execute
rescue => e
error!(e)
end
|
.error!(exception) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/duracloud/cli.rb', line 40
def self.error!(exception)
$stderr.puts exception.message
if [ ArgumentError, CommandError, OptionParser::ParseError ].include?(exception.class)
$stderr.puts HELP
end
exit(false)
end
|
Instance Method Details
#execute ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/duracloud/cli.rb', line 58
def execute
unless COMMANDS.include?(command)
raise CommandError, "Invalid command: #{command.inspect}."
end
configure_client
send(command, self)
end
|