Documentation
¶
Overview ¶
Package textfsm reads line-oriented text with a template: a state machine whose rules are regular expressions, in the form Google's TextFSM defined for parsing the output of network devices.
A template declares the values it captures, then the states it moves through. Each state is a list of rules, tried in order against the current line; the first to match assigns its captures and says what happens next: which line to read, whether to emit a record, and which state to enter.
Value Subject (.+)
Value List Body (.*)
Start
^${Subject} -> Body
Body
^${Body}
The result is a list of records, one per Record action plus the one implied at the end of input, each holding the captures that filled it -- with the line and column each capture came from, which is what places an alert.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capture ¶
A Capture is one piece of text a value took, and where it came from. Line and Column are 1-based, and Column counts runes.
type Record ¶
A Record is one emitted set of captures, keyed by value name. A List value holds every capture; any other holds one.
type Template ¶
type Template struct {
Values []Value
// contains filtered or unexported fields
}
A Template is a compiled state machine.
type Value ¶
type Value struct {
Name string
Regex string
// Filldown keeps the last capture across records; Required drops a
// record the value is missing from; List gathers every capture rather
// than the last one.
Filldown bool
Required bool
List bool
}
A Value is one named capture a template fills.