Class: Raindrop::CLI
- Inherits:
-
Object
- Object
- Raindrop::CLI
- Defined in:
- lib/raindrop/cli.rb
Constant Summary collapse
- SUCCESS =
0- FAILURE =
1- DEFAULT_SEARCH_LIMIT =
50- MAX_SEARCH_LIMIT =
50
Instance Method Summary collapse
-
#initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr, config: nil) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr, config: nil) ⇒ CLI
Returns a new instance of CLI.
20 21 22 23 24 25 26 |
# File 'lib/raindrop/cli.rb', line 20 def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr, config: nil) @argv = argv.dup @stdin = stdin @stdout = stdout @stderr = stderr @config = config || Config.new end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/raindrop/cli.rb', line 28 def run command = @argv.shift case command when "auth" run_auth(@argv) when "config" run_config(@argv) when "add" add(@argv) when "search" search(@argv) when "get" get(@argv) when "delete" delete(@argv) when "tags" (@argv) when "collections" collections(@argv) when "-h", "--help", nil print_usage SUCCESS else @stderr.puts "Unknown command: #{command}" print_usage(@stderr) FAILURE end rescue OptionParser::ParseError => e @stderr.puts e. FAILURE rescue Error => e @stderr.puts e. FAILURE end |