mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Factor out common usage-help code
This commit is contained in:
22
src/usage.cpp
Normal file
22
src/usage.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "usage.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void Usage::printAndExit(int code) const {
|
||||
fputs(usage, stderr);
|
||||
exit(code);
|
||||
}
|
||||
|
||||
void Usage::printAndExit(char const *fmt, ...) const {
|
||||
va_list args;
|
||||
fputs("FATAL: ", stderr);
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
putc('\n', stderr);
|
||||
|
||||
printAndExit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user