@@ -28,15 +28,15 @@ const helperBanner = `
2828// The default http address used for accessing the generated SVG file in case of -web flag is used.
2929const httpAddress = "http://localhost:8080"
3030
31- type MessageType int
32-
3331type result struct {
3432 path string
3533 triangles []triangle.Triangle
3634 points []triangle.Point
3735 err error
3836}
3937
38+ type MessageType int
39+
4040// The message types used accross the CLI application.
4141const (
4242 DefaultMessage MessageType = iota
@@ -113,19 +113,15 @@ func main() {
113113 var wg sync.WaitGroup
114114
115115 // Read destination file or directory.
116- dst , err := os .Stat (* destination )
116+ _ , err := os .Stat (* destination )
117117 if err != nil {
118- log .Fatalf (
119- decorateText ("Unable to get dir stats: %v" , ErrorMessage ),
120- decorateText (err .Error (), DefaultMessage ),
121- )
122- }
123-
124- //@TODO create destination directory in case it does not exists.
125-
126- // Check if the image destination is a directory or a file.
127- if dst .Mode ().IsRegular () {
128- log .Fatalf (decorateText ("Please specify a directory as destination!." , ErrorMessage ))
118+ err = os .Mkdir (* destination , 0755 )
119+ if err != nil {
120+ log .Fatalf (
121+ decorateText ("Unable to get dir stats: %v\n " , ErrorMessage ),
122+ decorateText (err .Error (), DefaultMessage ),
123+ )
124+ }
129125 }
130126
131127 // Process image files from directory concurrently.
@@ -148,6 +144,7 @@ func main() {
148144 wg .Wait ()
149145 }()
150146
147+ // Consume the channel values
151148 for res := range ch {
152149 showProcessStatus (res .path , res .triangles , res .points , res .err )
153150 }
@@ -190,7 +187,7 @@ func main() {
190187 procTime := time .Since (start )
191188 s .Stop ()
192189
193- fmt .Printf ("Generated in: %s\n " , decorateText (fmt .Sprintf ("%.2fs" , procTime .Seconds ()), SuccessMessage ))
190+ fmt .Printf ("Finished in: %s\n " , decorateText (fmt .Sprintf ("%.2fs" , procTime .Seconds ()), SuccessMessage ))
194191}
195192
196193// walkDir starts a goroutine to walk the specified directory tree
0 commit comments