Address most of the review feedback

This commit is contained in:
Jeff Mitchell
2016-01-15 10:41:29 -05:00
parent 4cc7694a3a
commit a25514d4f7
3 changed files with 69 additions and 38 deletions

View File

@@ -83,14 +83,25 @@ func (c *GenerateRootCommand) Run(args []string) int {
// If we are initing, or if we are not started but are not running a
// special function, check otp and pgpkey
if init ||
(!init && !cancel && !status && !genotp && len(decode) == 0 && !rootGenerationStatus.Started) {
checkOtpPgp := false
switch {
case init:
checkOtpPgp = true
case cancel:
case status:
case genotp:
case len(decode) != 0:
case rootGenerationStatus.Started:
default:
checkOtpPgp = true
}
if checkOtpPgp {
switch {
case len(otp) == 0 && (pgpKeyArr == nil || len(pgpKeyArr) == 0):
c.Ui.Error("-otp or -pgp-key must be specified")
c.Ui.Error(c.Help())
return 1
case len(otp) != 0 && pgpKeyArr != nil && len(pgpKeyArr) != 0:
c.Ui.Error("Only one of -otp or -pgp-key must be specified")
c.Ui.Error(c.Help())
return 1
case len(otp) != 0:
err := c.verifyOTP(otp)