mirror of
https://github.com/gbdev/rgbds.git
synced 2025-12-06 09:47:47 +00:00
Factor out version-printing to usage.cpp (#1870)
This commit is contained in:
@@ -13,6 +13,8 @@ struct Usage {
|
||||
std::vector<std::string> flags;
|
||||
std::vector<std::pair<std::vector<std::string>, std::vector<std::string>>> options;
|
||||
|
||||
void printVersion(bool error) const;
|
||||
|
||||
[[noreturn]]
|
||||
void printAndExit(int code) const;
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "usage.hpp"
|
||||
#include "util.hpp" // UpperMap
|
||||
#include "verbosity.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include "asm/charmap.hpp"
|
||||
#include "asm/fstack.hpp"
|
||||
@@ -296,7 +295,7 @@ static void parseArg(int ch, char *arg) {
|
||||
|
||||
// LCOV_EXCL_START
|
||||
case 'V':
|
||||
printf("%s %s\n", usage.name.c_str(), get_package_version_string());
|
||||
usage.printVersion(false);
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
@@ -381,7 +380,7 @@ static void verboseOutputConfig() {
|
||||
|
||||
style_Set(stderr, STYLE_MAGENTA, false);
|
||||
|
||||
fprintf(stderr, "%s %s\n", usage.name.c_str(), get_package_version_string());
|
||||
usage.printVersion(true);
|
||||
|
||||
printVVVVVVerbosity();
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "style.hpp"
|
||||
#include "usage.hpp"
|
||||
#include "util.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include "fix/fix.hpp"
|
||||
#include "fix/mbc.hpp"
|
||||
@@ -252,7 +251,7 @@ static void parseArg(int ch, char *arg) {
|
||||
|
||||
// LCOV_EXCL_START
|
||||
case 'V':
|
||||
printf("%s %s\n", usage.name.c_str(), get_package_version_string());
|
||||
usage.printVersion(false);
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "usage.hpp"
|
||||
#include "util.hpp"
|
||||
#include "verbosity.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include "gfx/pal_spec.hpp"
|
||||
#include "gfx/process.hpp"
|
||||
@@ -409,7 +408,7 @@ static void parseArg(int ch, char *arg) {
|
||||
|
||||
// LCOV_EXCL_START
|
||||
case 'V':
|
||||
printf("%s %s\n", usage.name.c_str(), get_package_version_string());
|
||||
usage.printVersion(false);
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
@@ -481,7 +480,7 @@ static void verboseOutputConfig() {
|
||||
|
||||
style_Set(stderr, STYLE_MAGENTA, false);
|
||||
|
||||
fprintf(stderr, "%s %s\n", usage.name.c_str(), get_package_version_string());
|
||||
usage.printVersion(true);
|
||||
|
||||
printVVVVVVerbosity();
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "usage.hpp"
|
||||
#include "util.hpp" // UpperMap, printChar
|
||||
#include "verbosity.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include "link/assign.hpp"
|
||||
#include "link/lexer.hpp"
|
||||
@@ -283,7 +282,7 @@ static void parseArg(int ch, char *arg) {
|
||||
|
||||
// LCOV_EXCL_START
|
||||
case 'V':
|
||||
printf("%s %s\n", usage.name.c_str(), get_package_version_string());
|
||||
usage.printVersion(false);
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
@@ -330,7 +329,7 @@ static void verboseOutputConfig() {
|
||||
|
||||
style_Set(stderr, STYLE_MAGENTA, false);
|
||||
|
||||
fprintf(stderr, "%s %s\n", usage.name.c_str(), get_package_version_string());
|
||||
usage.printVersion(true);
|
||||
|
||||
printVVVVVVerbosity();
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "helpers.hpp"
|
||||
#include "platform.hpp"
|
||||
#include "style.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define WIN32_LEAN_AND_MEAN // Include less from `windows.h`
|
||||
@@ -17,6 +18,10 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
void Usage::printVersion(bool error) const {
|
||||
fprintf(error ? stderr : stdout, "%s %s\n", name.c_str(), get_package_version_string());
|
||||
}
|
||||
|
||||
void Usage::printAndExit(int code) const {
|
||||
FILE *file;
|
||||
bool isTerminal;
|
||||
|
||||
Reference in New Issue
Block a user