From f728d4b7b1339e5d3a3fc5047910d955667696f9 Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Sun, 16 Oct 2022 16:17:04 -0700 Subject: [PATCH] args: add version command --- src/args.cpp | 9 +++++---- src/main.cpp | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/args.cpp b/src/args.cpp index de45904..a25cdd0 100644 --- a/src/args.cpp +++ b/src/args.cpp @@ -119,6 +119,11 @@ size_t getCommandArgs(int argc, char** argv, ecudump_args_t* args) if (c == -1) break; switch(c) { case 0: { + if (strcmp(long_options[option_index].name, "version") == 0) { + fprintf(stderr, "%s Version 0.9.0\n", argv[0] ? argv[0] : "ecudump"); + return 0; + } + if(strcmp(long_options[option_index].name, "start-address") == 0) { signed long long ret = decodeHex(optarg, 0xffffffff); if(ret < 0) { @@ -192,10 +197,6 @@ size_t getCommandArgs(int argc, char** argv, ecudump_args_t* args) args->verbose = true; break; } - if(strcmp(long_options[option_index].name, "version") == 0) { - fprintf(stderr, "ecudump version = 0.2.0"); - break; - } if(strcmp(long_options[option_index].name, "version") == 0) { command = 0; diff --git a/src/main.cpp b/src/main.cpp index 4a37e53..ce849a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -207,6 +207,8 @@ int main(int argc, char** argv) chunkRemainder ); } + if (command == 0) + return 1; if (j2534Initialize()) { LOGE(TAG, "j2534Initialize() failed");