mirror of https://github.com/mgba-emu/mgba.git
All: Add --version flag
This commit is contained in:
parent
c82f0ba5de
commit
cd2443356b
1
CHANGES
1
CHANGES
|
@ -46,6 +46,7 @@ Misc:
|
|||
- GBA Config: Add "override" layer for better one-time configuration
|
||||
- SDL: Allow GBASDLAudio to be used without a thread context
|
||||
- All: Improved PowerPC support
|
||||
- All: Add --version flag
|
||||
|
||||
0.3.0: (2015-08-16)
|
||||
Features:
|
||||
|
|
|
@ -47,6 +47,7 @@ static const struct option _options[] = {
|
|||
{ "help", no_argument, 0, 'h' },
|
||||
{ "movie", required_argument, 0, 'v' },
|
||||
{ "patch", required_argument, 0, 'p' },
|
||||
{ "version", no_argument, 0, '\0' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -68,8 +69,17 @@ bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int arg
|
|||
// TODO: modularize options to subparsers
|
||||
strncat(options, subparser->extraOptions, sizeof(options) - strlen(options) - 1);
|
||||
}
|
||||
while ((ch = getopt_long(argc, argv, options, _options, 0)) != -1) {
|
||||
int index = 0;
|
||||
while ((ch = getopt_long(argc, argv, options, _options, &index)) != -1) {
|
||||
const struct option* opt = &_options[index];
|
||||
switch (ch) {
|
||||
case '\0':
|
||||
if (strcmp(opt->name, "version") == 0) {
|
||||
opts->showVersion = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
GBAConfigSetOverrideValue(config, "bios", optarg);
|
||||
break;
|
||||
|
@ -122,7 +132,7 @@ bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int arg
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 1) {
|
||||
return opts->showHelp;
|
||||
return opts->showHelp || opts->showVersion;
|
||||
}
|
||||
opts->fname = strdup(argv[0]);
|
||||
return true;
|
||||
|
@ -228,7 +238,12 @@ void usage(const char* arg0, const char* extraOptions) {
|
|||
puts(" -v, --movie FILE Play back a movie of recorded input");
|
||||
puts(" -p, --patch FILE Apply a specified patch file when running");
|
||||
puts(" -s, --frameskip N Skip every N frames");
|
||||
puts(" --version Print version and exit");
|
||||
if (extraOptions) {
|
||||
puts(extraOptions);
|
||||
}
|
||||
}
|
||||
|
||||
void version(const char* arg0) {
|
||||
printf("%s %s (%s)\n", arg0, projectVersion, gitCommit);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ struct GBAArguments {
|
|||
enum DebuggerType debuggerType;
|
||||
bool debugAtStart;
|
||||
bool showHelp;
|
||||
bool showVersion;
|
||||
};
|
||||
|
||||
struct SubParser {
|
||||
|
@ -52,6 +53,7 @@ bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int arg
|
|||
void freeArguments(struct GBAArguments* opts);
|
||||
|
||||
void usage(const char* arg0, const char* extraOptions);
|
||||
void version(const char* arg0);
|
||||
|
||||
void initParserForGraphics(struct SubParser* parser, struct GraphicsOpts* opts);
|
||||
struct ARMDebugger* createDebugger(struct GBAArguments* opts, struct GBAThread* context);
|
||||
|
|
|
@ -67,6 +67,13 @@ int main(int argc, char** argv) {
|
|||
GBAConfigDeinit(&config);
|
||||
return !parsed;
|
||||
}
|
||||
if (args.showVersion) {
|
||||
version(argv[0]);
|
||||
freeArguments(&args);
|
||||
GBAConfigFreeOpts(&opts);
|
||||
GBAConfigDeinit(&config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GBAConfigMap(&config, &opts);
|
||||
|
||||
|
|
|
@ -67,6 +67,13 @@ int main(int argc, char** argv) {
|
|||
GBAContextDeinit(&context);
|
||||
return !parsed;
|
||||
}
|
||||
if (args.showVersion) {
|
||||
version(argv[0]);
|
||||
freeArguments(&args);
|
||||
GBAConfigFreeOpts(&opts);
|
||||
GBAConfigDeinit(&config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct GBAVideoSoftwareRenderer renderer;
|
||||
renderer.outputBuffer = 0;
|
||||
|
|
|
@ -77,6 +77,13 @@ int main(int argc, char** argv) {
|
|||
GBAConfigDeinit(&config);
|
||||
return !parsed;
|
||||
}
|
||||
if (args.showVersion) {
|
||||
version(argv[0]);
|
||||
freeArguments(&args);
|
||||
GBAConfigFreeOpts(&opts);
|
||||
GBAConfigDeinit(&config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
renderer.outputBuffer = malloc(256 * 256 * 4);
|
||||
renderer.outputBufferStride = 256;
|
||||
|
|
Loading…
Reference in New Issue