Class: Vimdb::Runner

Inherits:
Thor
  • Object
show all
Defined in:
lib/vimdb/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.common_search_optionsObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/vimdb/runner.rb', line 16

def self.common_search_options
  method_option :reload, :type => :boolean, :desc => 'reloads items'
  method_option :sort, :type => :string, :desc => 'sort by field', :aliases => '-s'
  method_option :reverse_sort, :type => :boolean, :aliases => '-R'
  method_option :ignore_case, :type => :boolean, :aliases => '-i'
  method_option :regexp, :type => :boolean, :aliases => '-r', :desc => 'query is a regexp'
  method_option :not, :type => :boolean, :aliases => '-n', :desc => 'return non-matching results'
  method_option :all, :type => :boolean, :aliases => '-a', :desc => 'search all fields'
  method_option :field, :type => :string, :desc => 'field to query', :aliases => '-f'
end

.start(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/vimdb/runner.rb', line 5

def self.start(*args)
  rc = ENV['VIMDB_RC'] || '~/.vimdbrc'
  begin
    load(rc) if File.exists?(File.expand_path(rc))
  rescue StandardError, SyntaxError, LoadError => err
    warn "Error while loading #{rc}:\n"+
      "#{err.class}: #{err.message}\n    #{err.backtrace.join("\n    ")}"
  end
  super
end

Instance Method Details

#commands(query = nil) ⇒ Object



44
45
46
47
# File 'lib/vimdb/runner.rb', line 44

def commands(query = nil)
  Vimdb.item('commands')
  search_item(query)
end

#info(item = nil) ⇒ Object



50
51
52
# File 'lib/vimdb/runner.rb', line 50

def info(item = nil)
  puts Vimdb.item(item).info
end

#keys(query = nil) ⇒ Object



30
31
32
33
# File 'lib/vimdb/runner.rb', line 30

def keys(query = nil)
  Vimdb.item('keys')
  search_item(query)
end

#opts(query = nil) ⇒ Object



37
38
39
40
# File 'lib/vimdb/runner.rb', line 37

def opts(query = nil)
  Vimdb.item('options')
  search_item(query)
end