From 2895ca0816507a9ca1ea19b5d990a1bb8299c9c4 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 20 Aug 2019 17:55:11 -0700 Subject: Support --version argument in command line tools (#2304) --- src/support/command-line.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp index f1b4fca4d..be5098677 100644 --- a/src/support/command-line.cpp +++ b/src/support/command-line.cpp @@ -15,6 +15,7 @@ */ #include "support/command-line.h" +#include "config.h" using namespace wasm; @@ -51,6 +52,14 @@ void printWrap(std::ostream& os, int leftPad, const std::string& content) { Options::Options(const std::string& command, const std::string& description) : debug(false), positional(Arguments::Zero) { + add("--version", + "", + "Output version information and exit", + Arguments::Zero, + [command](Options*, const std::string&) { + std::cout << command << " " << BINARYEN_VERSION_INFO << "\n"; + exit(0); + }); add("--help", "-h", "Show this help message and exit", -- cgit v1.2.3