From c0dad28145d0f72d6f1ecc15d5ecf86fc587ad23 Mon Sep 17 00:00:00 2001 From: 2gn <101851090+2gn@users.noreply.github.com> Date: Mon, 8 Dec 2025 08:53:32 +0900 Subject: [PATCH] implemented --active flag --- develop-requirements.txt | 2 +- nmcli/_connection.py | 6 ++++-- tests/test_connection.py | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/develop-requirements.txt b/develop-requirements.txt index 2fbb019..5afaa64 100644 --- a/develop-requirements.txt +++ b/develop-requirements.txt @@ -1,7 +1,7 @@ pytest==6.2.5 wheel==0.38.1 mypy==0.930 -pylint==2.12.2 +pylint==4.0.4 twine==3.7.1 autoflake==1.4 autopep8==1.6.0 diff --git a/nmcli/_connection.py b/nmcli/_connection.py index 93fb45d..49dfe90 100644 --- a/nmcli/_connection.py +++ b/nmcli/_connection.py @@ -31,7 +31,7 @@ def up(self, name: str, wait: int = None) -> None: def down(self, name: str, wait: int = None) -> None: raise NotImplementedError - def show(self, name: str, show_secrets: bool = False) -> ConnectionDetails: + def show(self, name: str, show_secrets: bool = False, active: bool = False) -> ConnectionDetails: raise NotImplementedError def reload(self) -> None: @@ -88,10 +88,12 @@ def down(self, name: str, wait: int = None) -> None: wait) + ['connection', 'down', name] self._syscmd.nmcli(cmd) - def show(self, name: str, show_secrets: bool = False) -> ConnectionDetails: + def show(self, name: str, show_secrets: bool = False, active: bool = False) -> ConnectionDetails: cmd = ['connection', 'show', name] if show_secrets: cmd += ["--show-secrets"] + if active: + cmd += ["--active"] r = self._syscmd.nmcli(cmd) results = {} for row in r.split('\n'): diff --git a/tests/test_connection.py b/tests/test_connection.py index 7b0a512..8cf488f 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -127,6 +127,10 @@ def test_show(): assert s.passed_parameters == [ 'connection', 'show', name, "--show-secrets"] + connection.show(name, active=True) + assert s.passed_parameters == [ + 'connection', 'show', name, "--active"] + def test_reload(): s = DummySystemCommand()