-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.go
62 lines (56 loc) · 1.57 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
package main
import (
"log"
"os"
"time"
"github.com/knadh/pfxsigner/internal/processor"
"github.com/urfave/cli"
)
var (
buildString = ""
proc *processor.Processor
logger *log.Logger
)
func init() {
logger = log.New(os.Stdout, "", log.Ldate|log.Ltime)
}
func main() {
app := cli.NewApp()
app.Name = "pfxsigner"
app.Usage = "utility for signing PDFs with PFX signatures"
app.Version = buildString
app.Action = func(c *cli.Context) error {
log.Println("no action to run. bye.")
return nil
}
app.Flags = []cli.Flag{
cli.StringSliceFlag{Name: "pfx", Value: nil, Usage: "PFX files. Can be specified multiple times. eg: mypfx|/path/to/cert.pfx|pfxpassword"},
cli.StringFlag{Name: "password", Value: "", Usage: "nest password"},
cli.StringFlag{Name: "props-file", Value: "props.json", Usage: "path to the JSON file with default signature properties", TakesFile: true},
}
app.Commands = []cli.Command{
// Request-response mode.
cli.Command{
Name: "cli",
Description: "run the utility in CLI mode",
Flags: []cli.Flag{
cli.IntFlag{Name: "workers", Value: 2,
Usage: "number of workers to run for signing"},
},
Action: initApp(initCLI),
},
// Stream mode.
cli.Command{
Name: "server",
Description: "run the utility in HTTP server mode",
Flags: []cli.Flag{
cli.StringFlag{Name: "address", Value: ":8000",
Usage: "address to listen on"},
cli.DurationFlag{Name: "timeout", Value: time.Second * 30,
Usage: "request timeout (eg: 10s)"},
},
Action: initApp(initServer),
},
}
app.Run(os.Args)
}