Class: BitClust::Subcommands::UpdateCommand

Inherits:
BitClust::Subcommand show all
Defined in:
lib/bitclust/subcommands/update_command.rb

Instance Method Summary collapse

Methods inherited from BitClust::Subcommand

#error, #help, #option_error, #srcdir_root

Constructor Details

#initializeUpdateCommand

Returns a new instance of UpdateCommand.


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bitclust/subcommands/update_command.rb', line 15

def initialize
  super
  @root = nil
  @library = nil
  @parser.banner = "Usage: #{File.basename($0, '.*')} update [<file>...]"
  @parser.on('--stdlibtree=ROOT', 'Process stdlib source directory tree.') {|path|
    @root = path
  }
  @parser.on('--library-name=NAME', 'Use NAME for library name in file mode.') {|name|
    @library = name
  }
end

Instance Method Details

#exec(argv, options) ⇒ Object


35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bitclust/subcommands/update_command.rb', line 35

def exec(argv, options)
  super
  @db.transaction {
    if @root
      @db.update_by_stdlibtree @root
    end
    argv.each do |path|
      @db.update_by_file path, @library || guess_library_name(path)
    end
  }
end

#parse(argv) ⇒ Object


28
29
30
31
32
33
# File 'lib/bitclust/subcommands/update_command.rb', line 28

def parse(argv)
  super
  if not @root and argv.empty?
    error "no input file given"
  end
end