diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-07-26 13:53:47 +0100 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-07-26 13:53:47 +0100 | 
| commit | 62bb5ac77e33b0432fbbf7da820e94dfe0c530bc (patch) | |
| tree | 3c38ab08911fbd59bc8b805fbeff9eca9599fdfc | |
| parent | Modernise dbUtils (diff) | |
| download | gentoobrowse-api-62bb5ac77e33b0432fbbf7da820e94dfe0c530bc.tar.bz2 gentoobrowse-api-62bb5ac77e33b0432fbbf7da820e94dfe0c530bc.tar.xz gentoobrowse-api-62bb5ac77e33b0432fbbf7da820e94dfe0c530bc.zip  | |
Fix warnings in update.cpp
| -rw-r--r-- | gentoobrowse-api/util/update.cpp | 39 | 
1 files changed, 19 insertions, 20 deletions
diff --git a/gentoobrowse-api/util/update.cpp b/gentoobrowse-api/util/update.cpp index f00cd0b..7f67ada 100644 --- a/gentoobrowse-api/util/update.cpp +++ b/gentoobrowse-api/util/update.cpp @@ -9,17 +9,16 @@  #include <exception>  #include <future>  #include <iostream> -#include <memory>  #include <string>  #include <vector>  namespace po = boost::program_options;  int -main(int c, char ** v) +main(int argc, char ** argv)  {  	std::string endpoint; -	bool background, tree, bugs, sendNotifications, pull; +	bool background {}, tree {}, bugs {}, sendNotifications {}, pull {};  	{  		po::options_description opts("Gentoo Browse Util::Update options");  		opts.add_options()("endpoint", po::value(&endpoint)->default_value("tcp -p 9001"), "Service endpoint")( @@ -29,48 +28,48 @@ main(int c, char ** v)  				"pull", po::value(&pull)->default_value(true), "Perform a git pull on repositories")("notifications",  				po::value(&sendNotifications)->default_value(true), "Send notification emails")("help,h", "Show help"); -		po::variables_map vm; -		po::store(po::command_line_parser(c, v).options(opts).run(), vm); -		po::notify(vm); +		po::variables_map varmap; +		po::store(po::command_line_parser(argc, argv).options(opts).run(), varmap); +		po::notify(varmap); -		if (vm.count("help")) { -			std::cerr << opts << std::endl; -			exit(1); +		if (varmap.contains("help")) { +			std::cerr << opts << '\n'; +			exit(EXIT_FAILURE);  		}  	} -	auto ic = Ice::initialize(c, v); -	auto m = Ice::checkedCast<Gentoo::MaintenancePrx>(ic->stringToProxy("maintenance:" + endpoint)); -	m->ice_ping(); +	auto ice = Ice::initialize(argc, argv); +	auto maintPrx = Ice::checkedCast<Gentoo::MaintenancePrx>(ice->stringToProxy("maintenance:" + endpoint)); +	maintPrx->ice_ping();  	std::vector<std::future<void>> jobs;  	if (bugs) { -		jobs.push_back(m->refreshBugsAsync()); +		jobs.push_back(maintPrx->refreshBugsAsync());  	}  	if (pull) { -		m->updateRepositories(); +		maintPrx->updateRepositories();  	}  	if (tree) { -		jobs.push_back(m->refreshPackageTreeAsync()); +		jobs.push_back(maintPrx->refreshPackageTreeAsync());  	}  	int failures = 0;  	if (!background) { -		std::for_each(jobs.begin(), jobs.end(), [&failures](auto & f) { +		std::ranges::for_each(jobs, [&failures](auto & future) {  			try { -				f.get(); +				future.get();  			}  			catch (const std::exception & ex) {  				failures += 1; -				std::cerr << ex.what() << std::endl; +				std::cerr << ex.what() << '\n';  			}  		});  		if (sendNotifications) { -			m->sendNotifications(); +			maintPrx->sendNotifications();  		}  	}  	jobs.clear(); -	ic->destroy(); +	ice->destroy();  	return failures;  }  | 
