Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/usage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions src/asm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions src/fix/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "style.hpp"
#include "usage.hpp"
#include "util.hpp"
#include "version.hpp"

#include "fix/fix.hpp"
#include "fix/mbc.hpp"
Expand Down Expand Up @@ -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':
Expand Down
5 changes: 2 additions & 3 deletions src/gfx/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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();

Expand Down
5 changes: 2 additions & 3 deletions src/link/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions src/usage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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;
Expand Down
Loading