@@ -333,26 +333,41 @@ def run_command_in_alias_mode(command):
333
333
elif output [0 ].isdigit ():
334
334
output = " " + output
335
335
print_output_in_alias_mode (output , index )
336
+
336
337
elif command .startswith ("nbrshow" ):
337
338
"""show arp"""
338
339
index = 2
339
340
if "Vlan" in output :
340
341
output = output .replace ('Vlan' , ' Vlan' )
341
342
print_output_in_alias_mode (output , index )
342
343
344
+ elif command .startswith ("sudo teamshow" ):
345
+ """
346
+ sudo teamshow
347
+ Search for port names either at the start of a line or preceded immediately by
348
+ whitespace and followed immediately by either the end of a line or whitespace
349
+ OR followed immediately by '(D)', '(S)', '(D*)' or '(S*)'
350
+ """
351
+ converted_output = raw_output
352
+ for port_name in iface_alias_converter .port_dict .keys ():
353
+ converted_output = re .sub (r"(^|\s){}(\([DS]\*{{0,1}}\)(?:$|\s))" .format (port_name ),
354
+ r"\1{}\2" .format (iface_alias_converter .name_to_alias (port_name )),
355
+ converted_output )
356
+ click .echo (converted_output .rstrip ('\n ' ))
357
+
343
358
else :
344
- if index :
345
- for port_name in iface_alias_converter . port_dict . keys ():
346
- regex = re . compile ( r"\b{}\b" . format ( port_name ))
347
- result = re . findall ( regex , raw_output )
348
- if result :
349
- interface_name = '' . join ( result )
350
- if not raw_output . startswith ( " PortID:" ):
351
- raw_output = raw_output . replace (
352
- interface_name ,
353
- iface_alias_converter .name_to_alias (
354
- interface_name ) )
355
- click .echo (raw_output .rstrip ('\n ' ))
359
+ """
360
+ Default command conversion
361
+ Search for port names either at the start of a line or preceded immediately by
362
+ whitespace and followed immediately by either the end of a line or whitespace
363
+ or a comma followed by whitespace
364
+ """
365
+ converted_output = raw_output
366
+ for port_name in iface_alias_converter . port_dict . keys ():
367
+ converted_output = re . sub ( r"(^|\s){}($|,{{0,1}}\s)" . format ( port_name ) ,
368
+ r"\1{}\2" . format ( iface_alias_converter .name_to_alias (port_name )),
369
+ converted_output )
370
+ click .echo (converted_output .rstrip ('\n ' ))
356
371
357
372
rc = process .poll ()
358
373
if rc != 0 :
0 commit comments