22from typing import List , Tuple
33
44from ._exception import ConnectionActivateFailedException
5- from ._helper import add_wait_option_if_needed
5+ from ._helper import add_wait_option_if_needed , add_fields_option_if_needed
66from ._system import SystemCommand , SystemCommandInterface
77from .data .device import Device , DeviceDetails , DeviceWifi
88from .data .hotspot import Hotspot
@@ -42,10 +42,10 @@ def __call__(self) -> List[Device]:
4242 def status (self ) -> List [Device ]:
4343 raise NotImplementedError
4444
45- def show (self , ifname : str ) -> DeviceDetails :
45+ def show (self , ifname : str , fields : str ) -> DeviceDetails :
4646 raise NotImplementedError
4747
48- def show_all (self ) -> List [DeviceDetails ]:
48+ def show_all (self , fields : str ) -> List [DeviceDetails ]:
4949 raise NotImplementedError
5050
5151 def connect (self , ifname : str , wait : int = None ) -> None :
@@ -101,8 +101,9 @@ def status(self) -> List[Device]:
101101 results .append (Device .parse (row ))
102102 return results
103103
104- def show (self , ifname : str ) -> DeviceDetails :
105- r = self ._syscmd .nmcli (['device' , 'show' , ifname ])
104+ def show (self , ifname : str , fields : str = None ) -> DeviceDetails :
105+ cmd = add_fields_option_if_needed (fields ) + ['device' , 'show' , ifname ]
106+ r = self ._syscmd .nmcli (cmd )
106107 results = {}
107108 for row in r .split ('\n ' ):
108109 m = re .search (r'^(\S+):\s*([\S\s]+)\s*' , row )
@@ -111,8 +112,9 @@ def show(self, ifname: str) -> DeviceDetails:
111112 results [key ] = None if value in ('--' , '""' ) else value
112113 return results
113114
114- def show_all (self ) -> List [DeviceDetails ]:
115- r = self ._syscmd .nmcli (['device' , 'show' ])
115+ def show_all (self , fields : str = None ) -> List [DeviceDetails ]:
116+ cmd = add_fields_option_if_needed (fields ) + ['device' , 'show' ]
117+ r = self ._syscmd .nmcli (cmd )
116118 results = []
117119 details : DeviceDetails = {}
118120 for row in r .split ('\n ' ):
0 commit comments