diff --git a/src/cli/Clip.cpp b/src/cli/Clip.cpp index 031a186223..0e2e6fb9be 100644 --- a/src/cli/Clip.cpp +++ b/src/cli/Clip.cpp @@ -81,7 +81,7 @@ int Clip::executeWithDatabase(QSharedPointer database, QSharedPointer< return EXIT_FAILURE; } else { bestEntryPath = (results.isEmpty()) ? args.at(1) : results[0]; - err << QObject::tr("Matching \"%1\" entry used.").arg(bestEntryPath) << endl; + out << QObject::tr("Matching \"%1\" entry used.").arg(bestEntryPath) << endl; } } else { bestEntryPath = args.at(1); diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp index 348afb670d..46fb54427c 100644 --- a/tests/TestCli.cpp +++ b/tests/TestCli.cpp @@ -504,6 +504,20 @@ void TestCli::testClip() setInput("a"); execCmd(clipCmd, {"clip", m_dbFile2->fileName(), "--attribute", "Username", "--totp", "/Sample Entry"}); QVERIFY(m_stderr->readAll().contains("ERROR: Please specify one of --attribute or --totp, not both.\n")); + + // Best option + setInput("a"); + execCmd(clipCmd, {"clip", m_dbFile->fileName(), "/Sample", "-b"}); + QCOMPARE(m_stdout->readAll(), QByteArray()); + QVERIFY(clipCmd.name.isEmpty()); + QVERIFY(m_stderr->readAll().contains("Sample Entry")); + QVERIFY(m_stderr->readAll().contains("Sample Entry 1")); + QVERIFY(m_stderr->readAll().contains("Sample Entry 2")); + + setInput("a"); + execCmd(clipCmd, {"clip", m_dbFile->fileName(), "/Entry 1", "-b"}); + QCOMPARE(m_stderr->readAll(), QByteArray()); + QTRY_COMPARE(clipboard->text(), QString("Password")); } void TestCli::testCreate()