-
Notifications
You must be signed in to change notification settings - Fork 5
/
web2imageMain.go
66 lines (54 loc) · 1.45 KB
/
web2imageMain.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
////////////////////////////////////////////////////////////////////////////
// Program: web2image
// Purpose: Web to image
// Authors: Tong Sun (c) 2017, All rights reserved
////////////////////////////////////////////////////////////////////////////
package main
//go:generate sh -v web2imageCLIGen.sh
import (
"fmt"
"os"
"github.com/labstack/gommon/color"
"github.com/mkideal/cli"
)
////////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
type rootOptsT struct {
Sleep string
WaitFor string
Verbose int
}
////////////////////////////////////////////////////////////////////////////
// Global variables definitions
var (
progname = "web2image"
VERSION = "0.1.0"
buildTime = "2017-07-23"
)
var (
rootArgv *rootT
rootOpts rootOptsT
)
////////////////////////////////////////////////////////////////////////////
// Function definitions
// Function main
func main() {
//NOTE: You can set any writer implements io.Writer
// default writer is os.Stdout
if err := cli.Root(root).Run(os.Args[1:]); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if rootOpts.Verbose >= 1 {
fmt.Println("Screenshot taken.")
}
os.Exit(0)
}
// abortOn will quit on anticipated errors gracefully without stack trace
func abortOn(errCase string, e error) {
if e != nil {
fmt.Fprintf(os.Stderr, "[%s] %s, %s: %v\n",
color.White(progname), color.Red("Error"), errCase, e)
os.Exit(1)
}
}