From 039e718a74c4d7eafa36c84341223937cd801bbc Mon Sep 17 00:00:00 2001 From: Carl Tashian Date: Tue, 13 Apr 2021 14:17:17 -0700 Subject: [PATCH] Add --quiet option to step ssh check-host --- command/ssh/checkHost.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/command/ssh/checkHost.go b/command/ssh/checkHost.go index cf2599db..0b29ee38 100644 --- a/command/ssh/checkHost.go +++ b/command/ssh/checkHost.go @@ -25,11 +25,11 @@ func checkHostCommand() cli.Command { Usage: "checks if a certificate has been issued for a host", UsageText: `**step ssh check-host** [**--ca-url**=] [**--root**=] -[**--offline**] [**--ca-config**=]`, +[**--offline**] [**--ca-config**=] [**--quiet**]`, Description: `**step ssh check-host** checks if a certificate has been issued for a host. -This command returns a zero exit status then the server exists, it will return 1 -otherwise. +This command prints "true" and returns a zero exit status if the host has a certificate. +Otherwise, it prints "false" and returns 1. ## POSITIONAL ARGUMENTS @@ -47,11 +47,17 @@ $ step ssh check-host internal.smallstep.com flags.Root, flags.Offline, flags.CaConfig, + cli.BoolFlag{ + Name: "quiet", + Usage: `Silently return an exit code.`, + }, }, } } func checkHostAction(ctx *cli.Context) error { + isQuiet := ctx.Bool("quiet") + if err := errs.NumberOfArguments(ctx, 1); err != nil { return err } @@ -96,7 +102,9 @@ func checkHostAction(ctx *cli.Context) error { "error checking ssh host eligibility") } - fmt.Println(resp.Exists) + if !isQuiet { + fmt.Println(resp.Exists) + } if !resp.Exists { os.Exit(1) }