diff --git a/OnePassword.NET/OnePasswordManager.cs b/OnePassword.NET/OnePasswordManager.cs index 07ef1e1..96bb93b 100644 --- a/OnePassword.NET/OnePasswordManager.cs +++ b/OnePassword.NET/OnePasswordManager.cs @@ -219,8 +219,10 @@ private string Op(string command, IEnumerable input, bool returnError) case Mode.Interactive: case Mode.AppIntegrated: default: - var passAccount = !(_mode == Mode.AppIntegrated || IsExcludedCommand(command, _excludedAccountCommands)); - if (passAccount && _account.Length == 0) + var excluded = IsExcludedCommand(command, _excludedAccountCommands); + var requireAccount = _mode != Mode.AppIntegrated && !excluded; + var passAccount = _account.Length != 0 && !excluded; + if (requireAccount && !passAccount) throw new InvalidOperationException("Cannot execute command because account has not been set."); var passSession = !(_mode == Mode.AppIntegrated || IsExcludedCommand(command, _excludedSessionCommands));