@@ -13,7 +13,10 @@ import (
13
13
"github.com/t1anz0ng/iftree/pkg"
14
14
)
15
15
16
- func Print (w io.Writer , vm map [string ][]pkg.Node , netNsMap map [int ]string , vpairs []pkg.Node ) error {
16
+ func Print (w io.Writer , vm map [string ][]pkg.Node ,
17
+ netNsMap map [int ]string ,
18
+ vpairs []pkg.Node ,
19
+ all bool ) error {
17
20
18
21
var content strings.Builder
19
22
var vpair strings.Builder
@@ -61,32 +64,33 @@ func Print(w io.Writer, vm map[string][]pkg.Node, netNsMap map[int]string, vpair
61
64
lw .SetStyle (list .StyleConnectedRounded )
62
65
lw .Render ()
63
66
64
- lw .Reset ()
65
- lw .SetOutputMirror (& vpair )
67
+ var contents []string
68
+ contents = append (contents , mainStype .Render (content .String ()))
69
+ if all {
70
+ lw .Reset ()
71
+ lw .SetOutputMirror (& vpair )
66
72
67
- fmt .Fprintln (& vpair , lipgloss .NewStyle ().
68
- Background (lipgloss .Color ("#F25D94" )).
69
- MarginLeft (5 ).
70
- MarginRight (5 ).
71
- Padding (0 , 1 ).
72
- Italic (true ).
73
- Foreground (lipgloss .Color ("#FFF7DB" )).
74
- SetString ("unused veth pairs" ))
75
- lw .SetStyle (list .StyleConnectedRounded )
76
- for _ , veth := range vpairs {
77
- lw .AppendItem (fmt .Sprintf ("%s%s%s" , veth .Veth ,
78
- lipgloss .NewStyle ().
79
- MarginRight (1 ).
80
- MarginLeft (1 ).
81
- Padding (0 , 1 ).
82
- Foreground (special ).SetString ("<----->" ),
83
- veth .Peer ))
73
+ fmt .Fprintln (& vpair , lipgloss .NewStyle ().
74
+ Background (lipgloss .Color ("#F25D94" )).
75
+ MarginLeft (5 ).
76
+ MarginRight (5 ).
77
+ Padding (0 , 1 ).
78
+ Italic (true ).
79
+ Foreground (lipgloss .Color ("#FFF7DB" )).
80
+ SetString ("unused veth pairs" ))
81
+ lw .SetStyle (list .StyleConnectedRounded )
82
+ for _ , veth := range vpairs {
83
+ lw .AppendItem (fmt .Sprintf ("%s%s%s" , veth .Veth ,
84
+ lipgloss .NewStyle ().
85
+ MarginRight (1 ).
86
+ MarginLeft (1 ).
87
+ Padding (0 , 1 ).
88
+ Foreground (special ).SetString ("<----->" ),
89
+ veth .Peer ))
90
+ }
91
+ lw .Render ()
92
+ contents = append (contents , vethPairStyle .Render (vpair .String ()))
84
93
}
85
- lw .Render ()
86
- fmt .Fprintln (w ,
87
- lipgloss .JoinHorizontal (
88
- lipgloss .Top ,
89
- mainStype .Render (content .String ()),
90
- vethPairStyle .Render (vpair .String ())))
94
+ fmt .Fprintln (w , lipgloss .JoinVertical (lipgloss .Top , contents ... ))
91
95
return nil
92
96
}
0 commit comments