@@ -84,56 +84,51 @@ func main() {
84
84
}
85
85
86
86
case "commit" :
87
- r , err := protolock .Commit (* cfg )
88
- if err != nil {
89
- fmt .Println (err )
90
- os .Exit (1 )
91
- }
92
-
93
87
// if force option is false (default), then disallow commit if
94
88
// there are any warnings encountered by runing a status check.
95
89
if ! * force {
96
- report , err := protolock .Status (* cfg )
97
- if err != nil {
98
- handleReport (report , err )
99
- }
100
-
101
- if len (report .Warnings ) > 0 {
102
- os .Exit (1 )
103
- }
90
+ status (cfg )
104
91
}
105
92
106
- err = saveToLockFile (* cfg , r )
93
+ r , err := protolock . Commit (* cfg )
107
94
if err != nil {
108
95
fmt .Println (err )
109
96
os .Exit (1 )
110
97
}
111
98
112
- case "status" :
113
- report , err := protolock .Status (* cfg )
114
- if err != protolock .ErrWarningsFound && err != nil {
115
- fmt .Println ("[protolock]:" , err )
99
+ err = saveToLockFile (* cfg , r )
100
+ if err != nil {
101
+ fmt .Println (err )
116
102
os .Exit (1 )
117
103
}
118
104
119
- // if plugins are provided, attempt to execute each as a exeutable
120
- // located in the user's OS executable path as reported by stdlib's
121
- // exec.LookPath func
122
- if * plugins != "" {
123
- report , err = runPlugins (* plugins , report )
124
- if err != nil {
125
- fmt .Println (err )
126
- os .Exit (1 )
127
- }
128
- }
129
-
130
- handleReport (report , err )
105
+ case "status" :
106
+ status (cfg )
131
107
132
108
default :
133
109
os .Exit (0 )
134
110
}
135
111
}
136
112
113
+ func status (cfg * protolock.Config ) {
114
+ report , err := protolock .Status (* cfg )
115
+ if err != protolock .ErrWarningsFound && err != nil {
116
+ fmt .Println ("[protolock]:" , err )
117
+ os .Exit (1 )
118
+ }
119
+ // if plugins are provided, attempt to execute each as a executable
120
+ // located in the user's OS executable path as reported by stdlib's
121
+ // exec.LookPath func
122
+ if * plugins != "" {
123
+ report , err = runPlugins (* plugins , report )
124
+ if err != nil {
125
+ fmt .Println (err )
126
+ os .Exit (1 )
127
+ }
128
+ }
129
+ handleReport (report , err )
130
+ }
131
+
137
132
func handleReport (report * protolock.Report , err error ) {
138
133
if len (report .Warnings ) > 0 {
139
134
0 commit comments