Class: Svn::Log::Application::SearchCommand

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

Overview

A command for searching an index

Defined Under Namespace

Classes: SvnLogTextPrinter, SvnLogXmlPrinter

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ SearchCommand

Returns a new instance of SearchCommand.



130
131
132
133
# File 'lib/svnlog.rb', line 130

def initialize(argv)
  parse_options(argv)
  @printer ||= SvnLogTextPrinter
end

Instance Method Details

#parse_options(argv) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/svnlog.rb', line 135

def parse_options(argv)
  OptionParser.new do |opt|
    opt.banner = <<END
Searches an index for log entries that match a query.

Examples:
  svnlog search -p C:\\MyIndex -q \"Fixed\"
  svnlog search -p C:\\MyIndex -q \"Fixed\" --xml

Usage: svnlog search [options]
END
    opt.on("-p", "--path <val>", "The path to the index") { |@path| }
    opt.on("-q", "--query <val>", "The search query") { |@query| }
    opt.on("-x", "--xml", "Output in XML") { @printer = SvnLogXmlPrinter }
    opt.parse!(argv)
  end
end

#runObject



153
154
155
156
# File 'lib/svnlog.rb', line 153

def run
  entries = Index.new(@path).search(@query)
  @printer.print entries
end