Function wasm_opt::integration::run_from_command_args
source · pub fn run_from_command_args(command: Command) -> Result<(), Error>
Expand description
Interpret a pre-built Command
as an OptimizationOptions
,
then call OptimizationOptions::run
on it.
This function is meant for easy integration with tools that already
call wasm-opt
via the command line, allowing them to use either
the command-line tool or the integrated API from a single Command
builder.
New programs that just need to optimize wasm should use OptimizationOptions
directly.
This function is provided on a best-effort basis to support programs
trying to integrate with the crate.
In general, it should support any command line options that are also supported
by the OptimizationOptions
API,
but it may not parse — and in some cases may not interpret —
those commands in exactly the same way.
It is meant to make it possible to produce a single command-line that works
with both the CLI and the API,
not to reproduce the behavior of the CLI perfectly.
The -o
argument is required, followed by a path —
the wasm-opt
tool writes the optimized module to stdout by default,
but this library is not currently capable of that.
-o
specifies a file in which to write the module.
If -o
is not provided, Error::OutputFileRequired
is returned.
Only the arguments to command
are interpreted;
environment variables and other settings are ignored.
§Errors
- Returns
Error::Unsupported
if any argument is not understood. - Returns
Error::OutputFileRequired
if the-o
argument and subsequent path are not provided.