Skip to content

Commit

Permalink
Add a wat2wasm subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
epatrizio committed May 28, 2024
1 parent a786bcc commit 940a9b3
Show file tree
Hide file tree
Showing 8 changed files with 752 additions and 6 deletions.
6 changes: 5 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ COMMANDS
Validate a module

wasm2wat [OPTION]… [ARG]…
Generate a text format file (.wat) file from a binary format file
Generate a text format file (.wat) from a binary format file
(.wasm)

wat2wasm [OPTION]… [ARG]…
Generate a binary format file (.wasm) from a text format file
(.wat)

COMMON OPTIONS
--help[=FMT] (default=auto)
Show this help in format FMT. The value FMT must be one of auto,
Expand Down
4 changes: 2 additions & 2 deletions example/wasm2wat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ $ owi wasm2wat ./42.wasm
```sh
$ owi wasm2wat --help=plain
NAME
owi-wasm2wat - Generate a text format file (.wat) file from a binary
format file (.wasm)
owi-wasm2wat - Generate a text format file (.wat) from a binary format
file (.wasm)

SYNOPSIS
owi wasm2wat [OPTION]… [ARG]…
Expand Down
16 changes: 14 additions & 2 deletions src/bin/owi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,25 @@ let wasm2wat_cmd =
let open Cmdliner in
let info =
let doc =
"Generate a text format file (.wat) file from a binary format file \
(.wasm)"
"Generate a text format file (.wat) from a binary format file (.wasm)"
in
let man = [] @ shared_man in
Cmd.info "wasm2wat" ~version ~doc ~sdocs ~man
in
Cmd.v info Term.(const Cmd_wasm2wat.cmd $ files)

let wat2wasm_cmd =
let open Cmdliner in
let info =
let doc =
"Generate a binary format file (.wasm) from a text format file (.wat)"
in
let man = [] @ shared_man in
Cmd.info "wat2wasm" ~version ~doc ~sdocs ~man
in
Cmd.v info
Term.(const Cmd_wat2wasm.cmd $ profiling $ debug $ unsafe $ optimize $ files)

let cli =
let open Cmdliner in
let info =
Expand All @@ -237,6 +248,7 @@ let cli =
; conc_cmd
; validate_cmd
; wasm2wat_cmd
; wat2wasm_cmd
]

let exit_code =
Expand Down
Loading

0 comments on commit 940a9b3

Please sign in to comment.