-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
98 lines (80 loc) · 3.55 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"flag"
"fmt"
"os"
"github.com/tacusci/clover/cltools"
"github.com/tacusci/logging"
)
const (
VER_NUM = "v0.0.2a"
)
func outputUsage() {
fmt.Printf("Clover - %s (c) tacusci ltd 2018\n", VER_NUM)
println("Usage: " + os.Args[0] + " </TOOLFLAG>")
fmt.Printf("\t/sdc (StorageDeviceChecker) - Tool for checking size of storage devices.\n")
fmt.Printf("\t/rtc (RawToCompressed) - Tool for batch compressing raw images.\n")
fmt.Printf("\t/tee (TIFFEXIFExport) - Tool for batch exporting of raw images EXIF data.")
}
func outputUsageAndClose() {
outputUsage()
os.Exit(1)
}
func setLoggingLevel() {
debugLevel := flag.Bool("debug", false, "Set logging to debug")
flag.Parse()
loggingLevel := logging.InfoLevel
if *debugLevel {
logging.SetLevel(logging.DebugLevel)
return
}
logging.SetLevel(loggingLevel)
}
func main() {
if len(os.Args) == 1 {
outputUsageAndClose()
}
runTool(os.Args[1])
}
func runTool(toolFlag string) {
//kind of hack to force flag parser to find tool argument flags correctly
os.Args = os.Args[1:]
switch toolFlag {
case "/sdc":
locationPath := flag.String("l", "", "Location to write data to.")
sizeToWrite := flag.Int("s", 0, "Size of total data to write.")
skipFileIntegrityCheck := flag.Bool("sic", false, "Skip verifying output file integrity.")
dontDeleteFiles := flag.Bool("nd", false, "Don't delete outputted files.")
setLoggingLevel()
flag.Parse()
cltools.RunSdc(*locationPath, *sizeToWrite, *skipFileIntegrityCheck, *dontDeleteFiles)
case "/rtc":
sourceDirectory := flag.String("id", "", "Location containing raw images to convert.")
outputDirectory := flag.String("od", "", "Location to save compressed images.")
inputType := flag.String("it", "", "Extension of image type to convert.")
outputType := flag.String("ot", "", "Extension of image type to output to.")
overwrite := flag.Bool("ow", false, "Overwrite existing images in output location.")
recursive := flag.Bool("rs", false, "Scan all sub folders in root recursively.")
retainFolderStructure := flag.Bool("fs", false, "Retain folder structure in output.")
showConversionOutput := flag.Bool("so", false, "Show conversion output.")
timeStamp := flag.Bool("ts", false, "Adds time stamp to show process duration in milliseconds in console output.")
logging.OutputDateTime, logging.OutputPath, logging.OutputLogLevelFlag, logging.OutputArrowSuffix = false, false, false, false
setLoggingLevel()
flag.Parse()
cltools.RunRtc(*timeStamp, *sourceDirectory, *outputDirectory, *inputType, *outputType, *showConversionOutput, *overwrite, *recursive, *retainFolderStructure)
case "/tee":
sourceDirectory := flag.String("id", "", "Location containing images from which to export EXIF data.")
outputDirectory := flag.String("od", "", "Location to save exported EXIF data.")
inputType := flag.String("it", "", "Extension of image type to export EXIF from.")
overwrite := flag.Bool("ow", false, "Overwrite existing export files in output location.")
recursive := flag.Bool("rs", false, "Scan all sub folders in root recursively.")
showConversionOutput := flag.Bool("so", false, "Show exporting output.")
timeStamp := flag.Bool("ts", false, "Adds time stamp to show process duration in milliseconds in console output.")
logging.OutputDateTime, logging.OutputPath, logging.OutputLogLevelFlag, logging.OutputArrowSuffix = false, false, false, false
setLoggingLevel()
flag.Parse()
cltools.RunTee(*timeStamp, *sourceDirectory, *outputDirectory, *inputType, *showConversionOutput, *overwrite, *recursive)
default:
outputUsageAndClose()
}
}