-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
76 lines (63 loc) · 2.06 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
package main
import (
"context"
"flag"
"fmt"
"os"
"github.com/fatih/color"
"github.com/google/subcommands"
)
var Version = "<dev>"
type versionCmd struct{}
func main() {
ctx := context.Background()
ctx = CtxWthErrPrintf(ctx, color.New(color.FgRed).PrintfFunc())
ctx = CtxWthErrPrintln(ctx, color.New(color.FgRed).PrintlnFunc())
cfg, err := buildAppConfig(ctx)
if err != nil {
ErrPrintf(ctx, "error getting app config: %s\n", err)
os.Exit(int(subcommands.ExitFailure))
}
ctx = CtxWthAppConfig(ctx, cfg)
subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(&versionCmd{}, "")
subcommands.Register(&installCmd{}, "")
subcommands.Register(&camswapCmd{}, "EXIF modification")
subcommands.Register(&rmlocCmd{}, "EXIF modification")
subcommands.Register(&inspectCmd{}, "EXIF inspection")
subcommands.Register(&neatImgCmd{}, "noise reduction")
subcommands.Register(&x3fJpgCmd{}, "Sigma X3F")
flag.Parse()
os.Exit(int(subcommands.Execute(ctx)))
}
func (*versionCmd) Name() string { return "version" }
func (*versionCmd) Synopsis() string { return "Print version and other information." }
func (p *versionCmd) SetFlags(_ *flag.FlagSet) {}
func (*versionCmd) Usage() string {
return `version:
Prints version, build, and other information about xtool.
`
}
func (p *versionCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
boldWhitePrintf := color.New(color.Bold, color.FgWhite).PrintfFunc()
boldWhitePrintf("xtool %s\n", Version)
fmt.Println(color.CyanString("https://www.github.com/cdzombak/xtool"))
fmt.Printf(
"a photo workflow tool by chris dzombak <%s>\n",
color.CyanString("https://www.dzombak.com"),
)
fmt.Println()
fmt.Printf(
"embedded x3f_extract: %s (installable via `%s`)\n",
X3fExtractVersion,
color.MagentaString("xtool install -x3f-extract"),
)
fmt.Println(color.CyanString("https://github.com/Kalpanika/x3f"))
fmt.Println()
fmt.Printf(
"run `%s` for usage.\n",
color.MagentaString("xtool help"),
)
fmt.Println()
return subcommands.ExitSuccess
}