public final class Lookup
extends java.lang.Object
grep
does. However, Lookup searches by entry
(by default, paragraphs) rather than by line, respects comments (ignores matches within them),
respects \include
directives (searches the named file), and has other features.
Each search criterion is a keyword or regular expression. Lookup outputs each entry that matches all the search criteria.
By default, search criteria are treated as keywords, and each paragraph is treated as an entry — in other words, Lookup prints each paragraph (in any of the files) that contains all the keywords, essentially performing paragraph-wise grep.
A file can contain one or more entries, each of which is a short entry or a long entry.
>entry
'. The remainder of
that line is a one-line description of the entry. A long entry is terminated by '<entry
', by the start of a new long entry, or by the start of a new file. Lookup searches
only the first line of a long entry.
By default, Lookup searches the file ~/lookup/root. Files can contain comments and can include other files. Comments start with a % sign in the first column. Any comment line is ignored (it is not treated as a blank line for the purpose of separating entries). A file can include another file via a line of the form '\include{filename}'.
The default behavior can be customized by way of command-line options.
The command-line options are as follows:
Modifier and Type | Field and Description |
---|---|
static boolean |
case_sensitive
If true, keywords matching is case sensistive.
|
static java.lang.String |
comment_re |
static java.util.regex.Pattern |
description_re |
static java.lang.String |
entry_file
Specify the colon-separated search list for the file that contains information to be searched.
|
static java.util.regex.Pattern |
entry_start_re |
static java.util.regex.Pattern |
entry_stop_re |
static boolean |
help
Show detailed help information and exit.
|
static java.lang.String |
include_re |
static java.lang.Integer |
item_num
Specifies which item to print when there are multiple matches.
|
static boolean |
print_all
By default, if multiple entries are matched, only a synopsis of each entry is printed.
|
static boolean |
regular_expressions
Specifies that keywords are regular expressions.
|
static boolean |
search_body
Search the body of long entries in addition to the entry's description.
|
static boolean |
show_location
If true, show the filename/line number of each matching entry in the output.
|
static boolean |
verbose |
static boolean |
word_match
If true, match a text keyword only as a separate word, not as a substring of a word.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
first_line(java.lang.String entry)
Returns the first line of entry.
|
static void |
main(java.lang.String[] args)
Look for the specified keywords in the file(s) and print the corresponding entries.
|
static EntryReader.Entry |
old_get_entry(EntryReader reader)
Returns the next entry.
|
public static boolean help
public static boolean verbose
public static java.lang.String entry_file
public static boolean search_body
public static boolean regular_expressions
public static boolean case_sensitive
public static boolean word_match
public static boolean print_all
public static java.lang.Integer item_num
public static boolean show_location
public static java.util.regex.Pattern entry_start_re
public static java.util.regex.Pattern entry_stop_re
public static java.util.regex.Pattern description_re
public static java.lang.String comment_re
public static java.lang.String include_re
public static void main(java.lang.String[] args) throws java.io.IOException
args
- command-line arguments; see documentationjava.io.IOException
- if there is a problem reading a filepublic static EntryReader.Entry old_get_entry(EntryReader reader) throws java.io.IOException
reader
- where to read the entry fromjava.io.IOException
- if there is a problem reading a filepublic static java.lang.String first_line(java.lang.String entry)
entry
- the entry whose first line to return