Class: CouchDocs::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/couch_docs/command_line.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CommandLine

Returns a new instance of CommandLine.



9
10
11
12
# File 'lib/couch_docs/command_line.rb', line 9

def initialize(args)
  @command = args.shift
  @options = args
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



7
8
9
# File 'lib/couch_docs/command_line.rb', line 7

def command
  @command
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/couch_docs/command_line.rb', line 7

def options
  @options
end

Class Method Details

.run(*args) ⇒ Object



3
4
5
# File 'lib/couch_docs/command_line.rb', line 3

def self.run(*args)
  CommandLine.new(*args).run
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/couch_docs/command_line.rb', line 14

def run
  case command
  when "dump"
    CouchDocs.dump(*options)
  when "load"
    CouchDocs.put_document_dir(*options.reverse)
  when "help", "--help", "-h"
    puts "#{$0} load dir         couchdb_uri"
    puts "#{$0} dump couchdb_uri dir"
  else
    raise ArgumentError.new("Unknown command #{command}")
  end
end