cli: Print own device always on top to fix test failures

* Otherwise tests fail when the name of the own device preceeds the other
  device names
* See https://github.com/Martchus/PKGBUILDs/issues/102
This commit is contained in:
Martchus 2021-01-11 18:49:35 +01:00
parent 76407c1f1e
commit 2eaddb0464
3 changed files with 15 additions and 13 deletions

View File

@ -11,7 +11,7 @@ set(META_APP_CATEGORIES "Network;FileTransfer")
set(META_GUI_OPTIONAL false)
set(META_VERSION_MAJOR 1)
set(META_VERSION_MINOR 1)
set(META_VERSION_PATCH 1)
set(META_VERSION_PATCH 2)
set(META_VERSION_EXACT_SONAME ON)
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)

View File

@ -623,17 +623,19 @@ void Application::printStatus(const ArgumentOccurrence &)
// display dirs
if (!m_relevantDirs.empty()) {
cout << TextAttribute::Bold << "Directories\n" << TextAttribute::Reset;
sort(m_relevantDirs.begin(), m_relevantDirs.end(),
[](const RelevantDir &dir1, const RelevantDir &dir2) { return dir1.dirObj->displayName() < dir2.dirObj->displayName(); });
for_each(m_relevantDirs.cbegin(), m_relevantDirs.cend(), bind(&Application::printDir, this, placeholders::_1));
std::sort(m_relevantDirs.begin(), m_relevantDirs.end(),
[](const RelevantDir &lhs, const RelevantDir &rhs) { return lhs.dirObj->displayName() < rhs.dirObj->displayName(); });
std::for_each(m_relevantDirs.cbegin(), m_relevantDirs.cend(), bind(&Application::printDir, this, std::placeholders::_1));
}
// display devs
if (!m_relevantDevs.empty()) {
cout << TextAttribute::Bold << "Devices\n" << TextAttribute::Reset;
sort(m_relevantDevs.begin(), m_relevantDevs.end(),
[](const SyncthingDev *dev1, const SyncthingDev *dev2) { return dev1->displayName() < dev2->displayName(); });
for_each(m_relevantDevs.cbegin(), m_relevantDevs.cend(), bind(&Application::printDev, this, placeholders::_1));
std::sort(m_relevantDevs.begin(), m_relevantDevs.end(), [](const SyncthingDev *lhs, const SyncthingDev *rhs) {
const auto lhsIsOwn = lhs->status == SyncthingDevStatus::OwnDevice, rhsIsOwn = rhs->status == SyncthingDevStatus::OwnDevice;
return lhsIsOwn != rhsIsOwn ? lhsIsOwn : lhs->displayName() < rhs->displayName();
});
std::for_each(m_relevantDevs.cbegin(), m_relevantDevs.cend(), bind(&Application::printDev, this, std::placeholders::_1));
}
cout.flush();

View File

@ -32,6 +32,12 @@ Directories
Rescan interval 2 h, file system watcher disabled
Devices
- .*
ID \w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w
Status own device
Addresses dynamic
Compression metadata
- Test dev 1
ID 6EIS2PN-J2IHWGS-AXS3YUL-HC5FT3K-77ZXTLL-AKQLJ4C-7SWVPUS-AZW4RQ4
Status disconnected
@ -43,9 +49,3 @@ Devices
Status paused
Addresses tcp://.*22001
Compression metadata
- .*
ID \w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w-\w\w\w\w\w\w\w
Status own device
Addresses dynamic
Compression metadata