pmt: CLeanup unnecessary function: real-link-path
- real-link-path function is removed. - Added --real-link-path flag to real-path function for as real-link-path.
This commit is contained in:
@@ -25,7 +25,6 @@ set(PMT_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/functions/MemoryTestFunction.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/functions/PartitionSizeFunction.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/functions/RealPathFunction.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/functions/RealLinkPathFunction.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/functions/RebootFunction.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/functions/TypeFunction.cpp
|
||||
)
|
||||
|
||||
@@ -96,8 +96,6 @@ int Main(int argc, char **argv) {
|
||||
AppMain);
|
||||
FuncManager.registerFunction(std::make_unique<infoFunction>(), AppMain);
|
||||
FuncManager.registerFunction(std::make_unique<realPathFunction>(), AppMain);
|
||||
FuncManager.registerFunction(std::make_unique<realLinkPathFunction>(),
|
||||
AppMain);
|
||||
FuncManager.registerFunction(std::make_unique<typeFunction>(), AppMain);
|
||||
FuncManager.registerFunction(std::make_unique<rebootFunction>(), AppMain);
|
||||
FuncManager.registerFunction(std::make_unique<memoryTestFunction>(),
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
Copyright 2025 Yağız Zengin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "functions.hpp"
|
||||
#include <PartitionManager/PartitionManager.hpp>
|
||||
|
||||
#define RLPFUN "realPathFunction"
|
||||
|
||||
namespace PartitionManager {
|
||||
bool realLinkPathFunction::init(CLI::App &_app) {
|
||||
LOGN(RLPFUN, INFO) << "Initializing variables of real link path function."
|
||||
<< std::endl;
|
||||
cmd = _app.add_subcommand("real-linkpath",
|
||||
"Tell real link paths of partition(s)");
|
||||
cmd->add_option("partition(s)", partitions, "Partition name(s)")
|
||||
->required()
|
||||
->delimiter(',');
|
||||
return true;
|
||||
}
|
||||
|
||||
bool realLinkPathFunction::run() {
|
||||
for (const auto &partition : partitions) {
|
||||
if (!Variables->PartMap->hasPartition(partition))
|
||||
throw Error("Couldn't find partition: %s", partition.data());
|
||||
|
||||
if (Variables->onLogical && !Variables->PartMap->isLogical(partition)) {
|
||||
if (Variables->forceProcess)
|
||||
LOGN(RLPFUN, WARNING)
|
||||
<< "Partition " << partition
|
||||
<< " is exists but not logical. Ignoring (from --force, -f)."
|
||||
<< std::endl;
|
||||
else
|
||||
throw Error("Used --logical (-l) flag but is not logical partition: %s",
|
||||
partition.data());
|
||||
}
|
||||
|
||||
println("%s", Variables->PartMap->getRealPathOf(partition).data());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool realLinkPathFunction::isUsed() const { return cmd->parsed(); }
|
||||
|
||||
const char *realLinkPathFunction::name() const { return RLPFUN; }
|
||||
} // namespace PartitionManager
|
||||
@@ -27,6 +27,7 @@ bool realPathFunction::init(CLI::App &_app) {
|
||||
cmd->add_option("partition(s)", partitions, "Partition name(s)")
|
||||
->required()
|
||||
->delimiter(',');
|
||||
cmd->add_flag("--real-link-path", realLinkPath, "Print real link path(s)")->default_val(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,7 +47,10 @@ bool realPathFunction::run() {
|
||||
partition.data());
|
||||
}
|
||||
|
||||
println("%s", Variables->PartMap->getRealPathOf(partition).data());
|
||||
if (realLinkPath)
|
||||
println("%s", Variables->PartMap->getRealLinkPathOf(partition).data());
|
||||
else
|
||||
println("%s", Variables->PartMap->getRealPathOf(partition).data());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -117,20 +117,7 @@ public:
|
||||
class realPathFunction final : public FunctionBase {
|
||||
private:
|
||||
std::vector<std::string> partitions;
|
||||
|
||||
public:
|
||||
CLI::App *cmd = nullptr;
|
||||
|
||||
bool init(CLI::App &_app) override;
|
||||
bool run() override;
|
||||
|
||||
[[nodiscard]] bool isUsed() const override;
|
||||
[[nodiscard]] const char *name() const override;
|
||||
};
|
||||
|
||||
class realLinkPathFunction final : public FunctionBase {
|
||||
private:
|
||||
std::vector<std::string> partitions;
|
||||
bool realLinkPath = false;
|
||||
|
||||
public:
|
||||
CLI::App *cmd = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user