google / textfsm

Python module for parsing semi-structured text into python tables.
Apache License 2.0
1.11k stars 171 forks source link

Documentation of "Key" optional Keyword #84

Open itdependsnetworks opened 4 years ago

itdependsnetworks commented 4 years ago

The word Key is getting overloaded here, but per my understanding of the documentation, the title is correct. There are Keywords (value, filldown, etc) and one of them is "Key". In the wiki it states:

"Key Declares that the fields contents contribute to the unique identifier for a row."

The one test that include "Key" shows a syntax in clitable also not documented in the "CLI Table" Wiki as well. Does this only work if using multiple templates as in that one test?

Anyway to get a quick explanation of how to use this?

harro commented 3 years ago

True the documentation is not sufficient in this area. Partly because it is primarily of used by downstream tooling although it could be used directly here for those interested.

The function is described in the source code https://github.com/google/textfsm/blob/master/textfsm/clitable.py#L168

And influences the Name Value Pair display format, which is documented briefly in TCLI https://github.com/google/tcli/wiki/TCLI-Power-Users-Guide#name-value-pairs-nvp ... note how columns are treated differently based on which ones are part of the key, or not. i.e. it determines which values are on the left vs right hand side of the NVP record displayed.

harro commented 3 years ago

I think perhaps the TCLI documentation needs expanding and a link between the two added here in TextFSM.