diff --git a/CMakeLists.txt b/CMakeLists.txt index a4fb8fe..08ac914 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cli/application.cpp b/cli/application.cpp index 9dd8e0d..f751f28 100644 --- a/cli/application.cpp +++ b/cli/application.cpp @@ -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(); diff --git a/cli/testfiles/expected-status.txt b/cli/testfiles/expected-status.txt index 7681d9c..d60b1a0 100644 --- a/cli/testfiles/expected-status.txt +++ b/cli/testfiles/expected-status.txt @@ -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