diff --git a/kadai1/tanaka0325/README.md b/kadai1/tanaka0325/README.md index dd5b852..e239401 100644 --- a/kadai1/tanaka0325/README.md +++ b/kadai1/tanaka0325/README.md @@ -24,7 +24,7 @@ ```zsh # build -$ go build -o ./imgconv +$ go build -o imgconv ./cmd/imgconv # display help $ ./imgconv -h diff --git a/kadai1/tanaka0325/imgconv.go b/kadai1/tanaka0325/imgconv.go deleted file mode 100644 index badc036..0000000 --- a/kadai1/tanaka0325/imgconv.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/gopherdojo/dojo8/kadai1/tanaka0325/converter" - -func main() { - converter.Convert() -} diff --git a/kadai1/tanaka0325/imgconv/cmd/imgconv/main.go b/kadai1/tanaka0325/imgconv/cmd/imgconv/main.go new file mode 100644 index 0000000..344f749 --- /dev/null +++ b/kadai1/tanaka0325/imgconv/cmd/imgconv/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "github.com/gopherdojo/dojo8/kadai1/tanaka0325/imgconv" +) + +func main() { + imgconv.Run() +} diff --git a/kadai1/tanaka0325/converter/conv_image.go b/kadai1/tanaka0325/imgconv/conv_image.go similarity index 98% rename from kadai1/tanaka0325/converter/conv_image.go rename to kadai1/tanaka0325/imgconv/conv_image.go index 2be5c9a..7a873e5 100644 --- a/kadai1/tanaka0325/converter/conv_image.go +++ b/kadai1/tanaka0325/imgconv/conv_image.go @@ -1,4 +1,4 @@ -package converter +package imgconv import ( "fmt" diff --git a/kadai1/tanaka0325/converter/exts.go b/kadai1/tanaka0325/imgconv/exts.go similarity index 91% rename from kadai1/tanaka0325/converter/exts.go rename to kadai1/tanaka0325/imgconv/exts.go index 5343d8d..ab81016 100644 --- a/kadai1/tanaka0325/converter/exts.go +++ b/kadai1/tanaka0325/imgconv/exts.go @@ -1,4 +1,4 @@ -package converter +package imgconv import "errors" diff --git a/kadai1/tanaka0325/go.mod b/kadai1/tanaka0325/imgconv/go.mod similarity index 54% rename from kadai1/tanaka0325/go.mod rename to kadai1/tanaka0325/imgconv/go.mod index 80a8fb1..ad64074 100644 --- a/kadai1/tanaka0325/go.mod +++ b/kadai1/tanaka0325/imgconv/go.mod @@ -1,4 +1,4 @@ -module github.com/gopherdojo/dojo8/kadai1/tanaka0325 +module github.com/gopherdojo/dojo8/kadai1/tanaka0325/imgconv go 1.14 diff --git a/kadai1/tanaka0325/go.sum b/kadai1/tanaka0325/imgconv/go.sum similarity index 100% rename from kadai1/tanaka0325/go.sum rename to kadai1/tanaka0325/imgconv/go.sum diff --git a/kadai1/tanaka0325/converter/convert.go b/kadai1/tanaka0325/imgconv/imgconv.go similarity index 86% rename from kadai1/tanaka0325/converter/convert.go rename to kadai1/tanaka0325/imgconv/imgconv.go index c5ee5c2..2edc0d1 100644 --- a/kadai1/tanaka0325/converter/convert.go +++ b/kadai1/tanaka0325/imgconv/imgconv.go @@ -1,4 +1,4 @@ -package converter +package imgconv import ( "flag" @@ -9,18 +9,23 @@ import ( "strings" ) -// flags var ( + // flags + f = flag.String("f", "jpg", "file extention before convert") + t = flag.String("t", "png", "file extention after convert") + dryRun = flag.Bool("n", false, "dry run") + + // allow extensions allowedExts = exts{"png", "jpg", "jpeg", "gif", "bmp", "tiff", "tif"} - f = flag.String("f", "jpg", "file extention before convert") - t = flag.String("t", "png", "file extention after convert") - dryRun = flag.Bool("n", false, "dry run") ) -// Convert is to convert image file format -func Convert() { - // check options ext +func init() { flag.Parse() +} + +// Run is to convert image file format +func Run() { + // check options ext to := strings.ToLower(*t) from := strings.ToLower(*f) targetExts := []string{to, from} diff --git a/kadai1/tanaka0325/testdata/images/sample1.jpg b/kadai1/tanaka0325/imgconv/testdata/images/sample1.jpg similarity index 100% rename from kadai1/tanaka0325/testdata/images/sample1.jpg rename to kadai1/tanaka0325/imgconv/testdata/images/sample1.jpg diff --git a/kadai1/tanaka0325/testdata/images2/img/sample3.jpg b/kadai1/tanaka0325/imgconv/testdata/images2/img/sample3.jpg similarity index 100% rename from kadai1/tanaka0325/testdata/images2/img/sample3.jpg rename to kadai1/tanaka0325/imgconv/testdata/images2/img/sample3.jpg diff --git a/kadai1/tanaka0325/testdata/images2/sample2.jpg b/kadai1/tanaka0325/imgconv/testdata/images2/sample2.jpg similarity index 100% rename from kadai1/tanaka0325/testdata/images2/sample2.jpg rename to kadai1/tanaka0325/imgconv/testdata/images2/sample2.jpg