Skip to content

device2yaml: add --newline option for quirky CLIs#3833

Open
Vantomas wants to merge 1 commit into
ytti:masterfrom
Vantomas:feature/device2yaml-newline
Open

device2yaml: add --newline option for quirky CLIs#3833
Vantomas wants to merge 1 commit into
ytti:masterfrom
Vantomas:feature/device2yaml-newline

Conversation

@Vantomas

Copy link
Copy Markdown
Contributor

Pre-Request Checklist

  • Passes rubocop code analysis (try rubocop --auto-correct)
  • Tests added or adapted (try rake test)
  • Changes are reflected in the documentation
  • User-visible changes appended to CHANGELOG.md

Description

extra/device2yaml.rb appends \n to every command it sends. Some quirky device CLIs (e.g. TP-Link) execute a command only on a \r\n, so with \n the commands are echoed but never run, and the captured simulation contains only the echoed commands with no output. There was no way to change this from the command line and each_line(chomp: true) strips a \r placed before the \n, so it can't be smuggled in via -c/-i.

This adds a -n/--newline option to control the line terminator:

  • Default stays "\n" (no behaviour change).
  • Accepts the \r, \n and \t escapes, e.g. -n '\r\n'.

Documented in docs/DeviceSimulation.md.

Example

bundle exec extra/device2yaml.rb user@host -n '\r\n' -c "show running-config"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant