File tree Expand file tree Collapse file tree 1 file changed +35
-2
lines changed
Expand file tree Collapse file tree 1 file changed +35
-2
lines changed Original file line number Diff line number Diff line change 44 "bufio"
55 "fmt"
66 "os"
7+ "path/filepath"
78 "regexp"
89 "strings"
910)
@@ -62,6 +63,7 @@ func handleLine(input string) {
6263}
6364
6465func processFile (fileName string ) int {
66+ fmt .Printf ("\n Reading file: %s\n " , fileName )
6567 file , err := os .Open (fileName )
6668 if err != nil {
6769 fmt .Printf ("Error reading file: %s.\n " , err .Error ())
@@ -92,6 +94,37 @@ func main() {
9294 os .Exit (1 )
9395 }
9496
95- var fileName string = arguments [1 ]
96- os .Exit (processFile (fileName ))
97+ if strings .Contains (arguments [1 ], ".scl" ) {
98+ var fileName string = arguments [1 ]
99+ os .Exit (processFile (fileName ))
100+ }
101+
102+ if strings .Contains (arguments [1 ], "--batch" ) {
103+ var errorCounter int
104+ err := filepath .WalkDir ("./" , func (path string , dirEntry os.DirEntry , err error ) error {
105+ if err != nil {
106+ return err
107+ }
108+ if ! dirEntry .IsDir () && filepath .Ext (dirEntry .Name ()) == ".scl" {
109+ errorCounter += processFile (path )
110+ }
111+
112+ return nil
113+ })
114+
115+ if errorCounter > 0 {
116+ fmt .Printf ("Coding standards not met.\n " )
117+ os .Exit (1 )
118+ }
119+
120+ if err != nil {
121+ fmt .Printf ("Error in batch processing: %v \n " , err )
122+ os .Exit (1 )
123+ }
124+
125+ }
126+
127+ fmt .Printf ("Unexpected parameters.\n " )
128+ os .Exit (1 )
129+
97130}
You can’t perform that action at this time.
0 commit comments