diff options
author | Alon Zakai <azakai@google.com> | 2022-01-05 11:42:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-05 11:42:13 -0800 |
commit | 16c9b3042d925270d1536429a239261b5a7df9b8 (patch) | |
tree | 4c27cdfa36afbb6e66f69b7dab4292aa76926ea9 /src/tools/wasm-reduce.cpp | |
parent | 79f76987ca899241a3f45d61e9b7964bcffb31a1 (diff) | |
download | binaryen-16c9b3042d925270d1536429a239261b5a7df9b8.tar.gz binaryen-16c9b3042d925270d1536429a239261b5a7df9b8.tar.bz2 binaryen-16c9b3042d925270d1536429a239261b5a7df9b8.zip |
Add categories to --help text (#4421)
The general shape of the --help output is now:
========================
wasm-foo
Does the foo operation
========================
wasm-foo opts:
--------------
--foo-bar ..
Tool opts:
----------
..
The options are now in categories, with the more specific ones - most likely to be
wanted by the user - first. I think this makes the list a lot less confusing.
In particular, in wasm-opt all the opt passes are now in their own category.
Also add a script to make it easy to update the help tests.
Diffstat (limited to 'src/tools/wasm-reduce.cpp')
-rw-r--r-- | src/tools/wasm-reduce.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index eff46bbcf..a6c195a63 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -1173,6 +1173,9 @@ int main(int argc, const char* argv[]) { std::string binDir = Path::getDirName(argv[0]); bool binary = true, deNan = false, verbose = false, debugInfo = false, force = false; + + const std::string WasmReduceOption = "wasm-reduce options"; + ToolOptions options("wasm-reduce", "Reduce a wasm file to a smaller one that has the same " "behavior on a given command"); @@ -1183,12 +1186,14 @@ int main(int argc, const char* argv[]) { "the command's output identical. " "We look at the command's return code and stdout here (TODO: stderr), " "and we reduce while keeping those unchanged.", + WasmReduceOption, Options::Arguments::One, [&](Options* o, const std::string& argument) { command = argument; }) .add("--test", "-t", "Test file (this will be written to to test, the given command should " "read it when we call it)", + WasmReduceOption, Options::Arguments::One, [&](Options* o, const std::string& argument) { test = argument; }) .add("--working", @@ -1196,11 +1201,13 @@ int main(int argc, const char* argv[]) { "Working file (this will contain the current good state while doing " "temporary computations, " "and will contain the final best result at the end)", + WasmReduceOption, Options::Arguments::One, [&](Options* o, const std::string& argument) { working = argument; }) .add("--binaries", "-b", "binaryen binaries location (bin/ directory)", + WasmReduceOption, Options::Arguments::One, [&](Options* o, const std::string& argument) { // Add separator just in case @@ -1210,33 +1217,39 @@ int main(int argc, const char* argv[]) { "-S", "Emit intermediate files as text, instead of binary (also make sure " "the test and working files have a .wat or .wast suffix)", + WasmReduceOption, Options::Arguments::Zero, [&](Options* o, const std::string& argument) { binary = false; }) .add("--denan", "", "Avoid nans when reducing", + WasmReduceOption, Options::Arguments::Zero, [&](Options* o, const std::string& argument) { deNan = true; }) .add("--verbose", "-v", "Verbose output mode", + WasmReduceOption, Options::Arguments::Zero, [&](Options* o, const std::string& argument) { verbose = true; }) .add("--debugInfo", "-g", "Keep debug info in binaries", + WasmReduceOption, Options::Arguments::Zero, [&](Options* o, const std::string& argument) { debugInfo = true; }) .add("--force", "-f", "Force the reduction attempt, ignoring problems that imply it is " "unlikely to succeed", + WasmReduceOption, Options::Arguments::Zero, [&](Options* o, const std::string& argument) { force = true; }) .add("--timeout", "-to", "A timeout to apply to each execution of the command, in seconds " "(default: 2)", + WasmReduceOption, Options::Arguments::One, [&](Options* o, const std::string& argument) { timeout = atoi(argument.c_str()); @@ -1246,6 +1259,7 @@ int main(int argc, const char* argv[]) { "-ef", "Extra commandline flags to pass to wasm-opt while reducing. " "(default: --enable-all)", + WasmReduceOption, Options::Arguments::One, [&](Options* o, const std::string& argument) { extraFlags = argument; |