summaryrefslogtreecommitdiff
path: root/src/libctor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libctor.cc')
-rw-r--r--src/libctor.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/libctor.cc b/src/libctor.cc
index 3eb6c6f..b1fbaea 100644
--- a/src/libctor.cc
+++ b/src/libctor.cc
@@ -15,6 +15,7 @@
#include <deque>
#include <fstream>
#include <cstdlib>
+#include <span>
#include <getoptpp/getoptpp.hpp>
@@ -27,6 +28,8 @@
int main(int argc, char* argv[])
{
+ auto args = std::span(argv, static_cast<std::size_t>(argc));
+
ctor::settings settings{};
const auto& c = ctor::get_configuration();
@@ -34,12 +37,12 @@ int main(int argc, char* argv[])
settings.parallel_processes =
std::max(1u, std::thread::hardware_concurrency()) * 2 - 1;
- if(argc > 1 && std::string(argv[1]) == "configure")
+ if(args.size() > 1 && std::string(args[1]) == "configure")
{
return configure(settings, argc, argv);
}
- if(argc > 1 && std::string(argv[1]) == "reconfigure")
+ if(args.size() > 1 && std::string(args[1]) == "reconfigure")
{
return reconfigure(settings, argc, argv);
}
@@ -64,7 +67,8 @@ int main(int argc, char* argv[])
[&]() {
try
{
- settings.parallel_processes = std::stoi(optarg);
+ settings.parallel_processes =
+ static_cast<std::size_t>(std::stoi(optarg));
}
catch(...)
{
@@ -100,7 +104,7 @@ int main(int argc, char* argv[])
"Add specified file to the build configurations.",
[&]() {
no_relaunch = true;
- add_files.push_back(optarg);
+ add_files.emplace_back(optarg);
return 0;
});
@@ -108,7 +112,7 @@ int main(int argc, char* argv[])
"Remove specified file from the build configurations.",
[&]() {
no_relaunch = true;
- remove_files.push_back(optarg);
+ remove_files.emplace_back(optarg);
return 0;
});
@@ -156,7 +160,7 @@ int main(int argc, char* argv[])
opt.add("help", no_argument, 'h',
"Print this help text.",
[&]() {
- std::cout << "Usage: " << argv[0] << " [options] [target] ...\n";
+ std::cout << "Usage: " << args[0] << " [options] [target] ...\n";
std::cout <<
R"_( where target can be either:
configure - run configuration step (cannot be used with other targets).
@@ -187,12 +191,12 @@ Options:
std::vector<std::string> files;
for(std::size_t i = 0; i < numConfigFiles; ++i)
{
- files.push_back(configFiles[i].file);
+ files.emplace_back(configFiles[i].file);
}
for(std::size_t i = 0; i < numExternalConfigFiles; ++i)
{
- files.push_back(externalConfigFiles[i].file);
+ files.emplace_back(externalConfigFiles[i].file);
}
std::sort(files.begin(), files.end());
@@ -270,7 +274,6 @@ Options:
if(print_configure_db)
{
no_default_build = true;
- const auto& c = ctor::get_configuration();
for(const auto& config : c.tools)
{
std::cout << config.first << ": " << config.second << "\n";