Add a --version option to cec-ctl to retrieve the version of cec-ctl. Signed-off-by: Paul Elder <paul.elder@xxxxxxxxxxxxxxxx> --- utils/cec-ctl/cec-ctl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp index 455cdaeb..d4a4f036 100644 --- a/utils/cec-ctl/cec-ctl.cpp +++ b/utils/cec-ctl/cec-ctl.cpp @@ -133,6 +133,7 @@ enum Option { OptVendorCommandWithID, OptVendorRemoteButtonDown, OptCustomCommand, + OptVersion, }; struct node { @@ -218,6 +219,8 @@ static struct option long_options[] = { { "unregistered", no_argument, 0, OptUnregistered }, { "help-all", no_argument, 0, OptHelpAll }, + { "version", no_argument, 0, OptVersion }, + CEC_PARSE_LONG_OPTS { "vendor-remote-button-down", required_argument, 0, OptVendorRemoteButtonDown }, \ @@ -231,6 +234,11 @@ static struct option long_options[] = { { 0, 0, 0, 0 } }; +static void version() +{ + printf("cec-ctl " PACKAGE_VERSION "\n"); +} + static void usage() { printf("Usage:\n" @@ -262,6 +270,7 @@ static void usage() " --help-all Show all help messages\n" " -T, --trace Trace all called ioctls\n" " -v, --verbose Turn on verbose reporting\n" + " --version Show version information\n" " -w, --wall-clock Show timestamps as wall-clock time (implies -v)\n" " -W, --wait-for-msgs Wait for messages and events for up to --monitor-time secs.\n" " --cec-version-1.4 Use CEC Version 1.4 instead of 2.0\n" @@ -2296,6 +2305,10 @@ int main(int argc, char **argv) break; } + case OptVersion: + version(); + std::exit(EXIT_SUCCESS); + default: if (ch >= OptHelpAll) { cec_parse_usage_options(options); -- 2.27.0