CLI: Add 'flatten' option to the 'ls' command (#3276)

* Fixes #925 
* Add 'flatten' option to CLI ls command
* Add test for Group::hierarchy() and man page for ls --flatten
* Rename group sort test to align with others
This commit is contained in:
Balazs Gyurak
2019-06-19 01:42:19 +01:00
committed by Jonathan White
parent 1e915eef89
commit 05c11d1b7c
10 changed files with 141 additions and 19 deletions

View File

@@ -847,7 +847,38 @@ void TestCli::testList()
"eMail/\n"
" [empty]\n"
"Homebanking/\n"
" [empty]\n"));
" Subgroup/\n"
" Subgroup Entry\n"));
pos = m_stdoutFile->pos();
Utils::Test::setNextPassword("a");
listCmd.execute({"ls", "-R", "-f", m_dbFile->fileName()});
m_stdoutFile->seek(pos);
m_stdoutFile->readLine(); // skip password prompt
QCOMPARE(m_stdoutFile->readAll(),
QByteArray("Sample Entry\n"
"General/\n"
"General/[empty]\n"
"Windows/\n"
"Windows/[empty]\n"
"Network/\n"
"Network/[empty]\n"
"Internet/\n"
"Internet/[empty]\n"
"eMail/\n"
"eMail/[empty]\n"
"Homebanking/\n"
"Homebanking/Subgroup/\n"
"Homebanking/Subgroup/Subgroup Entry\n"));
pos = m_stdoutFile->pos();
Utils::Test::setNextPassword("a");
listCmd.execute({"ls", "-R", "-f", m_dbFile->fileName(), "/Homebanking"});
m_stdoutFile->seek(pos);
m_stdoutFile->readLine(); // skip password prompt
QCOMPARE(m_stdoutFile->readAll(),
QByteArray("Subgroup/\n"
"Subgroup/Subgroup Entry\n"));
pos = m_stdoutFile->pos();
Utils::Test::setNextPassword("a");
@@ -921,7 +952,8 @@ void TestCli::testLocate()
locateCmd.execute({"locate", tmpFile.fileName(), "Entry"});
m_stdoutFile->seek(pos);
m_stdoutFile->readLine(); // skip password prompt
QCOMPARE(m_stdoutFile->readAll(), QByteArray("/Sample Entry\n/General/New Entry\n"));
QCOMPARE(m_stdoutFile->readAll(),
QByteArray("/Sample Entry\n/General/New Entry\n/Homebanking/Subgroup/Subgroup Entry\n"));
}
void TestCli::testMerge()