Skip to content

Commit

Permalink
💡 fix: Change cmd_multiline to receive commands as *args instead of l…
Browse files Browse the repository at this point in the history
…ist - fixed #35
  • Loading branch information
henriquesebastiao committed Aug 30, 2024
1 parent 77641ae commit 6b0ea93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions netmikro/routeros.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

from netmikro.modules import Ip, System


Expand Down Expand Up @@ -71,11 +69,11 @@ def cmd(self, command: str) -> str:
expect_string=rf'\[{self._username}@[^]]+\]',
)

def cmd_multiline(self, commands: List[str]) -> str:
def cmd_multiline(self, *args) -> str:
"""Runs multiple commands in the router's terminal.
Args:
commands (List[str]): List of commands to be executed.
*args (str): List of commands to be executed.
Returns:
str: Output of the commands.
Expand All @@ -87,4 +85,5 @@ def cmd_multiline(self, commands: List[str]) -> str:
... ])
['name: Netmikro', 'note: Test']
"""
commands = [x for x in args]
return self._connection.send_multiline(commands)
4 changes: 2 additions & 2 deletions tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def test_cmd(router):


def test_cmd_multilines(router):
output = router.cmd_multiline([
output = router.cmd_multiline(
'return [/system identity get name]',
'return [/system note get note]',
])
)

assert router.identity in output
assert 'Test note' in output
Expand Down

0 comments on commit 6b0ea93

Please sign in to comment.