66
77 "github.com/spf13/cobra"
88 "github.com/toob-boot/toob/internal/abi"
9+ "github.com/toob-boot/toob/internal/ui"
910)
1011
1112var abiCmd = & cobra.Command {
@@ -29,32 +30,33 @@ var abiCheckCmd = &cobra.Command{
2930 oldFile := args [0 ]
3031 newFile := args [1 ]
3132
32- fmt .Printf ("Analyzing ABI changes...\n " )
33- fmt .Printf (" Baseline: %s\n " , oldFile )
34- fmt .Printf (" New: %s\n \n " , newFile )
33+ ui .Step ("Analyzing ABI changes..." )
34+ ui .KeyValue ("Baseline" , oldFile )
35+ ui .KeyValue ("New" , newFile )
36+ ui .Divider ()
3537
3638 res , err := abi .Compare (oldFile , newFile )
3739 if err != nil {
3840 return fmt .Errorf ("analysis failed: %w" , err )
3941 }
4042
4143 if res .BumpType == abi .BumpPatch {
42- fmt . Printf ( " \033 [32m✔ ABI is perfectly compatible.\033 [0m \n " )
43- fmt . Printf ("Recommended SemVer bump: \033 [1;32mPATCH \033 [0m \n " )
44+ ui . Success ( " ABI is perfectly compatible." )
45+ ui . Info ("Recommended SemVer bump: %s" , ui . BoldGreen ( "PATCH" ) )
4446 return nil
4547 }
4648
47- fmt . Printf ( " \033 [33mABI Changes Detected:\033 [0m \n " )
48- fmt .Println ( res .Report )
49+ ui . Warn ( "ABI Changes Detected:" )
50+ fmt .Fprintln ( os . Stderr , res .Report )
4951
5052 switch res .BumpType {
5153 case abi .BumpMajor :
52- fmt . Printf ("Recommended SemVer bump: \033 [1;31mMAJOR \033 [0m (Incompatible/ Breaking Changes)\n " )
53- os .Exit (1 ) // Exit with code 1 so CI pipelines can block this if necessary
54+ ui . Error ("Recommended SemVer bump: %s ( Breaking Changes)" , ui . BoldRed ( "MAJOR" ) )
55+ os .Exit (1 )
5456 case abi .BumpMinor :
55- fmt . Printf ("Recommended SemVer bump: \033 [1;33mMINOR \033 [0m (Backwards-Compatible Additions) \n " )
57+ ui . Info ("Recommended SemVer bump: %s (Backwards-Compatible)" , ui . Bold ( "MINOR" ) )
5658 default :
57- fmt . Printf ("Recommended SemVer bump: \033 [1;31mUNKNOWN \033 [0m \n " )
59+ ui . Warn ("Recommended SemVer bump: %s" , ui . BoldRed ( "UNKNOWN" ) )
5860 }
5961
6062 return nil
@@ -73,12 +75,12 @@ var abiBaselineCmd = &cobra.Command{
7375 outFile = inFile + ".abi.xml"
7476 }
7577
76- fmt . Printf ("Generating baseline for %s... \n " , inFile )
78+ ui . Step ("Generating baseline for %s" , inFile )
7779 if err := abi .GenerateBaseline (inFile , outFile ); err != nil {
7880 return err
7981 }
8082
81- fmt . Printf ( " \033 [32m✔ Baseline successfully generated:\033 [0m %s\n " , outFile )
83+ ui . Success ( " Baseline generated: %s" , outFile )
8284 return nil
8385 },
8486}
0 commit comments