Add version

This commit is contained in:
Aurélie Delhaie
2023-10-08 17:27:59 +02:00
parent ab31e2e3ff
commit e236d59c71
3 changed files with 57 additions and 4 deletions

25
main.go
View File

@@ -17,6 +17,18 @@ import (
"github.com/mojitaurelie/heic2jpg/exif"
)
const (
VERSION = "0.1.0"
usageDescription = `heic2jpg - v%s.%s.%s.%s
Note: <file> is ignored when -dir is set
Usage: heic2jpg [OPTIONS] <file>
OPTIONS:
`
)
type (
filer interface {
IsDir() bool
@@ -25,11 +37,15 @@ type (
)
func usage() {
fmt.Printf("Usage: %s [OPTIONS] <file>\n\n", os.Args[0])
fmt.Printf("Note: <file> is ignored when -dir is set\n\nOPTIONS:\n")
fmt.Printf(usageDescription, VERSION, runtime.Version(), runtime.GOOS, runtime.GOARCH)
flag.PrintDefaults()
}
func version() {
fmt.Printf("heic2jpg - v%s.%s.%s.%s\n", VERSION, runtime.Version(), runtime.GOOS, runtime.GOARCH)
os.Exit(0)
}
func main() {
go func() {
if r := recover(); r != nil {
@@ -48,8 +64,13 @@ func main() {
removeOrig := flag.Bool("remove-original", false, "Remove the heic file after conversion")
overwriteOut := flag.Bool("overwrite", false, "Overwrite file if already exists")
outPath := flag.String("o", "", "Output directory")
v := flag.Bool("v", false, "Show version")
flag.Parse()
if *v {
version()
}
if *jpegQuality < 1 || *jpegQuality > 100 {
fmt.Println("W: Illegal value for jpeg quality, quality is set to ", jpeg.DefaultQuality)
*jpegQuality = jpeg.DefaultQuality