-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.go
145 lines (141 loc) · 3.86 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package main
import (
"github.com/digitorus/pdfsigner/cmd"
"github.com/digitorus/pdfsigner/version"
)
var (
// Version of the application set at build time
Version = "undefined"
// BuildDate of the application set at build time
BuildDate string
// GitCommit of the application set at build time
GitCommit string
// GitBranch of the application set at build time
GitBranch string
)
func main() {
ver := version.Version{
Version: Version,
BuildDate: BuildDate,
GitCommit: GitCommit,
GitBranch: GitBranch,
}
cmd.Execute(ver)
}
//
//func main() {
// // if no flags provided print usage
// if len(os.Args) == 1 {
// //usage()
// return
// }
//
//
// log.Println(cfgFile)
// switch os.Args[1] {
// case "sign":
// signCmd()
// case "verify":
// //verifyPDF()
// case "serve":
// case "watch":
// default:
// fmt.Printf("%q is not valid command.\n", os.Args[1])
// os.Exit(2)
// }
//
//
//}
//
//func signCmd() {
// signCommand := flag.NewFlagSet("sign", flag.ExitOnError)
// switch os.Args[2] {
// case "pksc11":
// //pksc11sign(signCommand)
// case "ssl":
// //sslSign(signCommand)
// case "signer":
// signCmd()
// default:
// fmt.Printf("%q is not valid command.\n", os.Args[2])
// os.Exit(2)
// }
//
// signCommand.Parse(os.Args[2:])
//}
//
//var (
// cfgFile string
// signatureApproval bool
// signatureType uint
// signatureInfoName string
// signatureInfoLocation string
// signatureInfoReason string
// signatureInfoContact string
// signatureTSAUrl string
// signatureTSAUsername string
// signatureTSAPassword string
// signerNameFlag string
// certificateChainPath string
// certificatePath string
// privateKeyPath string
// pksc11LibPath string
// pksc11Pass string
//)
//
//type configSigner struct {
// Name string
// SignerType string
// CrtPath string
// KeyPath string
// LibPath string
// Pass string
// CrtChainPath string
// Signature sign.SignDataSignature
// TSA sign.TSA
//}
//
//var signers []configSigner
//
//func parseSignDataFlags(cmd *flag.FlagSet, c configSigner) {
// cmd.BoolVar(&signatureApproval, "approval", c.Signature.Approval, "Approval")
// cmd.UintVar(&signatureType, "type", uint(c.Signature.CertType), "Certificate type")
// cmd.StringVar(&signatureInfoName, "name", c.Signature.Info.Name, "Signature info name")
// cmd.StringVar(&signatureInfoLocation, "location", c.Signature.Info.Location, "Signature info location")
// cmd.StringVar(&signatureInfoReason, "reason", c.Signature.Info.Reason, "Signature info reason")
// cmd.StringVar(&signatureInfoContact, "contact", c.Signature.Info.ContactInfo, "Signature info contact")
// cmd.StringVar(&signatureTSAUrl, "tsa-url", c.TSA.URL, "TSA url")
// cmd.StringVar(&signatureTSAUsername, "tsa-username", c.TSA.Username, "TSA username")
// cmd.StringVar(&signatureTSAPassword, "tsa-password", c.TSA.Password, "TSA password")
// cmd.StringVar(&certificateChainPath, "chain", c.CrtChainPath, "Certificate chain")
// cmd.StringVar(&cfgFile, "config", "", "config file (default is $HOME/.pdfsigner.yaml)")
// cmd.Parse(os.Args[2:])
//}
//
//// initConfig reads in config file and ENV variables if set.
//func initConfig() {
// log.Print(cfgFile)
// if cfgFile != "" {
// // Use config file from the flag.
// viper.SetConfigFile(cfgFile)
// } else {
// // Find home directory.
// home, err := homedir.Dir()
// if err != nil {
// fmt.Println(err)
// os.Exit(1)
// }
//
// // Search config in home directory with name ".pdfsigner" (without extension).
// viper.AddConfigPath(home)
// viper.SetConfigName(".pdfsigner")
// }
//
// viper.AutomaticEnv() // read in environment variables that match
// // If a config file is found, read it in.
// if err := viper.ReadInConfig(); err == nil {
// fmt.Println("Using config file:", viper.ConfigFileUsed())
// }
//
// viper.UnmarshalKey("signer", &signers)
//}