File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,17 +39,20 @@ func Format(opts Option) {
3939 group [result .Url .Host ] = append (group [result .Url .Host ], & result )
4040 }
4141
42- // 分组
43-
4442 for _ , results := range group {
4543 for _ , result := range results {
4644 if ! opts .Fuzzy && result .IsFuzzy {
4745 continue
4846 }
49- if ! opts .NoColor {
50- logs .Log .Console (result .ColorString () + "\n " )
47+ if opts .OutputProbe == "" {
48+ if ! opts .NoColor {
49+ logs .Log .Console (result .ColorString () + "\n " )
50+ } else {
51+ logs .Log .Console (result .String () + "\n " )
52+ }
5153 } else {
52- logs .Log .Console (result .String () + "\n " )
54+ probes := strings .Split (opts .OutputProbe , "," )
55+ logs .Log .Console (result .ProbeOutput (probes ) + "\n " )
5356 }
5457 }
5558 }
Original file line number Diff line number Diff line change @@ -364,7 +364,7 @@ func (r *Runner) Output(bl *pkg.Baseline) {
364364 if r .Option .Json {
365365 out = bl .ToJson ()
366366 } else if len (r .Probes ) > 0 {
367- out = bl .Format (r .Probes )
367+ out = bl .ProbeOutput (r .Probes )
368368 } else if r .Color {
369369 out = bl .ColorString ()
370370 } else {
@@ -385,7 +385,7 @@ func (r *Runner) Output(bl *pkg.Baseline) {
385385 } else if r .FileOutput == "full" {
386386 r .OutputFile .SafeWrite (bl .String () + "\n " )
387387 } else {
388- r .OutputFile .SafeWrite (bl .Format (strings .Split (r .FileOutput , "," )) + "\n " )
388+ r .OutputFile .SafeWrite (bl .ProbeOutput (strings .Split (r .FileOutput , "," )) + "\n " )
389389 }
390390
391391 r .OutputFile .SafeSync ()
Original file line number Diff line number Diff line change @@ -235,6 +235,15 @@ func (bl *Baseline) Compare(other *Baseline) int {
235235 return - 1
236236}
237237
238+ func (bl * Baseline ) ProbeOutput (format []string ) string {
239+ var s strings.Builder
240+ for _ , f := range format {
241+ s .WriteString ("\t " )
242+ s .WriteString (bl .Get (f ))
243+ }
244+ return strings .TrimSpace (s .String ())
245+ }
246+
238247var Distance uint8 = 5 // 数字越小越相似, 数字为0则为完全一致.
239248
240249func (bl * Baseline ) FuzzyCompare (other * Baseline ) bool {
You can’t perform that action at this time.
0 commit comments