From 117ab372be230570a36c5d65e75a6689e2190943 Mon Sep 17 00:00:00 2001 From: Joey Gibson Date: Sat, 23 Jan 2021 00:32:45 -0500 Subject: [PATCH] made head and tail mutually exclusive --- README.md | 2 +- main.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c32f2df..c93cc6e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A tool to count the rows, and take rows from [Vertica native binary files](http ## Usage ```bash -Usage: verticat [-cfHv] [-h value] [-o value] [-t value] [parameters ...] +Usage: verticat [-cfHv] [-h value] [-o value] [-t value] -c, --count count rows -f, --force force overwrite of output file -h, --head=value take the first n rows diff --git a/main.go b/main.go index 27f11d1..f26324f 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ func main() { getopt.SetParameters("") getopt.Parse() + args := getopt.Args() if *helpFlag { @@ -46,7 +47,13 @@ func main() { } if len(args) == 0 { - _, _ = fmt.Fprintln(os.Stderr, "no file given") + _, _ = fmt.Fprintf(os.Stderr, "Error: no file given\n\n") + getopt.PrintUsage(os.Stderr) + os.Exit(1) + } + + if *headRows > 0 && *tailRows > 0 { + fmt.Fprintf(os.Stderr, "Error: --head and --tail are mutually exclusive\n\n") getopt.PrintUsage(os.Stderr) os.Exit(1) }