From a38318e6afc2da9793a957d2cb0bc7c7ad78098c Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Sun, 29 Nov 2015 21:31:48 -0800 Subject: [PATCH] check for pipe args --- pipe-main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pipe-main.go b/pipe-main.go index 501301cd..ee8ac941 100644 --- a/pipe-main.go +++ b/pipe-main.go @@ -63,7 +63,14 @@ EXAMPLES: `, } -// pipe writes contents of stdin a collection of URLs. +// Validate command line arguments. +func checkPipeSyntax(ctx *cli.Context) { + if !ctx.Args().Present() || len(ctx.Args()) != 1 { + exitCode := 1 + cli.ShowCommandHelpAndExit(ctx, "pipe", exitCode) + } +} + func pipe(targetURL string) *probe.Error { if len(targetURL) == 0 || targetURL == "" { // When no target is specified, pipe cat's stdin to stdout. @@ -87,6 +94,9 @@ func pipe(targetURL string) *probe.Error { // mainPipe is the main entry point for pipe command. func mainPipe(ctx *cli.Context) { + // Check cmd args. + checkPipeSyntax(ctx) + // Set global flags from context. setGlobalsFromContext(ctx)