Skip to content

Commit

Permalink
Added new package to give colour output to terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
amnuts committed Oct 31, 2023
1 parent 4abe4d7 commit 11c3ff4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module changeme
go 1.18

require (
github.com/fatih/color v1.15.0
github.com/mmcloughlin/geohash v0.10.0
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd
github.com/wailsapp/wails/v2 v2.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
Expand Down
11 changes: 6 additions & 5 deletions path_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"github.com/fatih/color"
"github.com/mmcloughlin/geohash"
"github.com/rwcarlsen/goexif/exif"
"github.com/wailsapp/wails/v2/pkg/runtime"
Expand Down Expand Up @@ -237,31 +238,31 @@ func RelocateFiles(a *App) {

sourceFile, err := os.Open(a.substitutions[i].From)
if err != nil {
fmt.Println("Source file error", err)
color.Red("Source file error: %s", err)
continue
}

destinationFile, err := os.Create(destinationPath)
if err != nil {
fmt.Println("Destination file error", err)
color.Red("Destination file error: %s", err)
sourceFile.Close()
continue
}
defer destinationFile.Close()

if _, err := io.Copy(destinationFile, sourceFile); err != nil {
fmt.Println("Failed to copy", err)
color.Red("Failed to copy: %s", err)
sourceFile.Close()
continue
}

sourceFile.Close()

if a.moveOrCopy == "move" {
fmt.Println("Removing", a.substitutions[i].From)
color.Yellow("Removing %s", a.substitutions[i].From)
err := os.Remove(a.substitutions[i].From)
if err != nil {
fmt.Println("Remove error", err)
color.Red("Remove error: %s", err)
continue
}
}
Expand Down

0 comments on commit 11c3ff4

Please sign in to comment.