-
Notifications
You must be signed in to change notification settings - Fork 10
/
pmq-grep.go
30 lines (27 loc) · 1.02 KB
/
pmq-grep.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
package main
import (
"flag"
"fmt"
"github.com/actionpay/postmanq/application"
"github.com/actionpay/postmanq/common"
)
func main() {
var file, envelope, recipient string
var numberLines int
flag.StringVar(&file, "f", common.ExampleConfigYaml, "configuration yaml file")
flag.StringVar(&envelope, "e", common.InvalidInputString, "necessary envelope")
flag.StringVar(&recipient, "r", common.InvalidInputString, "necessary recipient")
flag.Parse()
app := application.NewGrep()
if app.IsValidConfigFilename(file) && recipient != common.InvalidInputString {
app.SetConfigFilename(file)
app.RunWithArgs(envelope, recipient, numberLines)
} else {
fmt.Println("Usage: pmq-grep -f -r [-e]")
flag.VisitAll(common.PrintUsage)
fmt.Println("Example:")
fmt.Printf(" pmq-grep -f %s -r mail@example.com\n", common.ExampleConfigYaml)
fmt.Printf(" pmq-grep -f %s -r mail@example.com -n 1000\n", common.ExampleConfigYaml)
fmt.Printf(" pmq-grep -f %s -r mail@example.com -e sender@mail.com\n", common.ExampleConfigYaml)
}
}