diff --git a/internal/cmd/commands/targetscmd/funcs.go b/internal/cmd/commands/targetscmd/funcs.go index 52292e1ee..8e247e995 100644 --- a/internal/cmd/commands/targetscmd/funcs.go +++ b/internal/cmd/commands/targetscmd/funcs.go @@ -324,14 +324,18 @@ func extraFlagsHandlingFuncImpl(c *Command, _ *base.FlagSets, opts *[]targets.Op case "set-credential-libraries": // TODO: As we add other purposes, add them to this check - if len(c.flagApplicationCredentialLibraries) == 0 { + switch len(c.flagApplicationCredentialLibraries) { + case 0: c.UI.Error("No credential-libraries supplied via -application-credential-library") return false - } - *opts = append(*opts, targets.WithApplicationCredentialLibraryIds(c.flagApplicationCredentialLibraries)) - if len(c.flagApplicationCredentialLibraries) == 1 && c.flagApplicationCredentialLibraries[0] == "null" { - // Clear all library ids since the only value set is a null. - *opts = append(*opts, targets.DefaultApplicationCredentialLibraryIds()) + case 1: + if c.flagApplicationCredentialLibraries[0] == "null" { + *opts = append(*opts, targets.DefaultApplicationCredentialLibraryIds()) + break + } + fallthrough + default: + *opts = append(*opts, targets.WithApplicationCredentialLibraryIds(c.flagApplicationCredentialLibraries)) } case "authorize-session":