Class: EverboxClient::CLI
- Inherits:
-
Object
- Object
- EverboxClient::CLI
- Defined in:
- lib/everbox_client/cli.rb
Constant Summary collapse
- SUPPORTED_COMMANDS =
{ "login" => "login", "ls" => "list files and directories", "lsdir" => "list directories", "get" => "download file", "put" => "upload file", "prepare_put" => "prepare put", "cd" => "change dir", "pwd" => "print working dir", "mkdir" => "make directory", "rm" => "delete file or directory", "mirror" => "download dir", "info" => "show user info", "config" => "set config", "cat" => "cat file", "help" => "print help info", "thumbnail" => "get thumbnail url" }
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(stdout, stdin, stderr, arguments = []) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
36 37 38 39 40 41 42 43 |
# File 'lib/everbox_client/cli.rb', line 36 def initialize @options = {} # don't dump a backtrace on a ^C trap(:INT) { exit } end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
28 29 30 |
# File 'lib/everbox_client/cli.rb', line 28 def command @command end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
29 30 31 |
# File 'lib/everbox_client/cli.rb', line 29 def @options end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
30 31 32 |
# File 'lib/everbox_client/cli.rb', line 30 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
30 31 32 |
# File 'lib/everbox_client/cli.rb', line 30 def stdout @stdout end |
Class Method Details
.execute(stdout, stdin, stderr, arguments = []) ⇒ Object
32 33 34 |
# File 'lib/everbox_client/cli.rb', line 32 def self.execute(stdout, stdin, stderr, arguments = []) self.new.execute(stdout, stdin, stderr, arguments) end |
Instance Method Details
#execute(stdout, stdin, stderr, arguments = []) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/everbox_client/cli.rb', line 45 def execute(stdout, stdin, stderr, arguments = []) @stdout = stdout @stdin = stdin @stderr = stderr (arguments) parse_env if valid_command? begin runner = EverboxClient::Runner.new @opts runner.send @command, *@args runner.dump_config rescue => e raise e STDERR.write "Error: #{e.}\n" exit 1 end else usage end end |