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