Class: SimpleCataloger::CmdServer

Inherits:
OptParseCommand::Command
  • Object
show all
Defined in:
lib/dircat/cat_on_sqlite_cli/cmd_server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.commandObject



8
9
10
# File 'lib/dircat/cat_on_sqlite_cli/cmd_server.rb', line 8

def self.command
  "server"
end

.descriptionObject



12
13
14
# File 'lib/dircat/cat_on_sqlite_cli/cmd_server.rb', line 12

def self.description
  "start server"
end

.usageObject



16
17
18
19
# File 'lib/dircat/cat_on_sqlite_cli/cmd_server.rb', line 16

def self.usage
  "#{command}  <catalog name>\n" +
  "launch a webs server to browse the content of <catalog name>\n"
end

Instance Method Details

#defaults(options) ⇒ Object



21
22
23
24
# File 'lib/dircat/cat_on_sqlite_cli/cmd_server.rb', line 21

def defaults(options)
  options.force = false
  options
end

#exec(main, options, rest) ⇒ Object



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
# File 'lib/dircat/cat_on_sqlite_cli/cmd_server.rb', line 31

def exec(main, options, rest)
  if rest.length < 1
    puts "too few arguments"
    puts "-h to print help"
    return 0
  end

  catalog_name = rest[0]
  cat_opts     = { }

  #
  # option verbose
  #

#    if options.has_key?(:verbose)
#      if options[:verbose]
#        cat_opts[:verbose_level] = 1
#      end
#    end

  #
  # main
  #

  catalog = SimpleCataloger::CatOnSqlite.new(catalog_name).open
  SimpleCataloger::WebServer.run! :host => 'localhost', :port => 9091, :catalog => catalog

  0
end

#option_parser(options) ⇒ Object



26
27
28
29
# File 'lib/dircat/cat_on_sqlite_cli/cmd_server.rb', line 26

def option_parser(options)
  parser = super(options)
  parser
end