SYNOPSYS import "clive/cmd/look" var Debug bool ... func ParseRules(txt string) (Rules, error) type Rule struct { ... } type Rules []*Rule func ParseRules(txt string) (Rules, error) DESCRIPTION Return commands to run when the user looks for strings. Programs rely on this package to "plumb" user looks. By convention, $look, or $home/lib/look, or $home/.look are used to keep the rules. A rule is a pair of lines, the first line is a regular expression as provided by sre(2) and the second is the command to execute for the rule. The special command "not" can be used to prevent further rules to match. Back-references may be used to build a command from parts of the matching text. CONSTANTS TYPES type Rule struct { Rexp string Cmd string sync.Mutex // contains filtered or unexported fields } If the user looks for something matching Rexp, then Cmd leads to a result string. Backquoting to refer to \0...\9 is ok in Cmd. func (r *Rule) CmdFor(s string) (string, error) Return the command to run if s matches the rule. ErrNoMatch is returned if there's no match. type Rules []*Rule func ParseRules(txt string) (Rules, error) func (rs Rules) CmdFor(s string) (string, error) Return the command for a user look, if any. ErrNoMatch is returned if no rule matches. If there's an error in any of the rules, no further rules are attempted. func (rs Rules) String() string Return a string that can be parsed later on by ParseRules to make a set of rules. FUNCTIONS VARIABLES var ( Debug bool ErrNoMatch = errors.New("no match") )
Clive, 2nd ed. User's manual. Section 2