google / google/textfsm

Import Functionality [Feature Request]

Open
#62 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
1.2k
Forks
194
PR merge metrics
No merged PRs in 30d

Description

Breakout from #18 to better discuss and judge interest.

Often it is useful to have two states that are very similar, with a few different expressions. Since Continue and state transitions are disallowed due to possible infinite loop issues, a way of reducing development time and redundant SLOC would be to allow a state to import another state which would be evaluated as a setup time macro.

E.g:

```
Start
\
$$IMPORT ToImportState
\

ToImportState
\
^\S -> Start
```

Questions:
1. is there interest in this feature?
2. is there interest in a separate import feature that does not allow the imported statements to initiate a state transition?
3. What might the syntax look like? Currently the $$IMPORT is a placeholder.

Potential issues:
1. Cyclical dependencies. This would be solved by not importing anything which has already been imported into a state. Another option would be only to allow immediate imports.
2. Debug output statements would become slightly more complex. A current suggestion is to provide a back trace like: `line: 10.102.50` where line 50 is the error, but was imported by line 102, which was in turn imported from line 10, which is your current state.
3. This would likely add complexity to the visual debugger #48 .
4. Unless using only immediate imports as a simple copy-paste macro, or forgoing a reasonable debug output, this feature would add a decent amount of complexity to multiple parts of the code.

Personally, when I was writing/editing/maintaining templates this feature probably would have saved me a few hours a month in development time. Which is to say it would have been nice but clearly wasn't a deal-breaker.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.