Skip to content

Commit 5b93f8d

Browse files
committed
SHOP-14072: fixing commandline interface
1 parent 9704c2a commit 5b93f8d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Requires Go version 1.7 or higher.
4343

4444
Run `binlog-parser -h` to get the list of available options:
4545

46-
Usage: binlog-parser binlog [options ...]
46+
Usage: binlog-parser [options ...] binlog
4747

4848
Options are:
4949

src/zalora/binlog-parser/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ func main() {
2121

2222
flag.Parse()
2323

24-
if len(os.Args) < 2 {
24+
if flag.NArg() != 1 {
2525
printUsage()
2626
os.Exit(1)
2727
}
2828

29-
binlogFilename := os.Args[2]
29+
binlogFilename := flag.Arg(0)
3030
dbDsn := os.Getenv("DB_DSN")
3131

3232
if dbDsn == "" {
@@ -51,17 +51,17 @@ func consumerChainFromArgs() parser.ConsumerChain {
5151
chain.CollectAsJson(os.Stdout, *prettyPrintJsonFlag)
5252
glog.V(1).Infof("Pretty print JSON %s", *prettyPrintJsonFlag)
5353

54-
if includeTablesFlag != nil {
54+
if *includeTablesFlag != "" {
5555
includeTables := commaSeparatedListToArray(*includeTablesFlag)
5656

5757
chain.IncludeTables(includeTables...)
5858
glog.V(1).Infof("Including tables %v", includeTables)
5959
}
6060

61-
if includeSchemasFlag != nil {
61+
if *includeSchemasFlag != "" {
6262
includeSchemas := commaSeparatedListToArray(*includeSchemasFlag)
6363

64-
chain.IncludeTables(includeSchemas...)
64+
chain.IncludeSchemas(includeSchemas...)
6565
glog.V(1).Infof("Including schemas %v", includeSchemas)
6666
}
6767

@@ -73,7 +73,7 @@ func printUsage() {
7373

7474
usage := "Parse a binlog file, dump JSON to stdout. Includes options to filter by schema and table.\n" +
7575
"Reads from information_schema database to find out the field names for a row event.\n\n" +
76-
"Usage:\t%s binlog [options ...]\n\n" +
76+
"Usage:\t%s [options ...] binlog\n\n" +
7777
"Options are:\n\n"
7878

7979
fmt.Fprintf(os.Stderr, usage, binName)

0 commit comments

Comments
 (0)