From 7e705fd92c214d6a9f96f2ac4a93ce03897db718 Mon Sep 17 00:00:00 2001
From: Joel Dice
Date: Thu, 11 Jul 2024 10:59:49 -0600
Subject: [PATCH 1/6] add unstable `exit-with-code` function
Whereas the existing `exit` function only accepts a `result` parameter
(i.e. binary success or failure), this function allows the instance to report
any status code from 0 to 255 to the host, with 0 usually meaning "success" and
other values having their own meaning depending on the context.
Fixes #11
Signed-off-by: Joel Dice
---
wit/exit.wit | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/wit/exit.wit b/wit/exit.wit
index d0c2b82..fa9b189 100644
--- a/wit/exit.wit
+++ b/wit/exit.wit
@@ -1,4 +1,9 @@
interface exit {
/// Exit the current instance and any linked instances.
exit: func(status: result);
+
+ /// Exit the current instance and any linked instances, reporting the
+ /// specified status code to the host.
+ @unstable(feature = exit-with-code)
+ exit-with-code: func(status-code: u8);
}
From d0dd1851728f05b26c4e3fb1c3b97de30014ddf7 Mon Sep 17 00:00:00 2001
From: Joel Dice
Date: Thu, 11 Jul 2024 11:21:57 -0600
Subject: [PATCH 2/6] expand `exit-with-code` documentation a bit
Signed-off-by: Joel Dice
---
wit/exit.wit | 3 +++
1 file changed, 3 insertions(+)
diff --git a/wit/exit.wit b/wit/exit.wit
index fa9b189..ec02c08 100644
--- a/wit/exit.wit
+++ b/wit/exit.wit
@@ -4,6 +4,9 @@ interface exit {
/// Exit the current instance and any linked instances, reporting the
/// specified status code to the host.
+ ///
+ /// The meaning of the code depends on the context, with 0 usually meaning
+ /// "success", and other values indicating various types of failure.
@unstable(feature = exit-with-code)
exit-with-code: func(status-code: u8);
}
From 1655c724f80b599b540edb8604ec1bede37b5446 Mon Sep 17 00:00:00 2001
From: Joel Dice
Date: Tue, 16 Jul 2024 13:10:27 -0600
Subject: [PATCH 3/6] add additional doc comment per code review
Signed-off-by: Joel Dice
---
wit/exit.wit | 3 +++
1 file changed, 3 insertions(+)
diff --git a/wit/exit.wit b/wit/exit.wit
index ec02c08..ad37361 100644
--- a/wit/exit.wit
+++ b/wit/exit.wit
@@ -7,6 +7,9 @@ interface exit {
///
/// The meaning of the code depends on the context, with 0 usually meaning
/// "success", and other values indicating various types of failure.
+ ///
+ /// This function does not return; the effect is analogous to a trap, but
+ /// without the connotation that something bad has happened.
@unstable(feature = exit-with-code)
exit-with-code: func(status-code: u8);
}
From af5d03cb0a773be6ae15973a4699d002f7ac9d09 Mon Sep 17 00:00:00 2001
From: Bailey Hayes
Date: Thu, 1 Aug 2024 11:32:19 -0400
Subject: [PATCH 4/6] ci: add exit-with-code to ci
---
.github/workflows/main.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 767e091..3080d98 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -21,4 +21,5 @@ jobs:
- uses: WebAssembly/wit-abi-up-to-date@v17
with:
wit-bindgen: '0.16.0'
- worlds: "command imports"
+ worlds: 'command imports'
+ features: 'exit-with-code'
From e384058d6f9df85287a358e67cc0660790460e1a Mon Sep 17 00:00:00 2001
From: Bailey Hayes
Date: Thu, 1 Aug 2024 11:37:32 -0400
Subject: [PATCH 5/6] fix: feature gate naming convention
---
.github/workflows/main.yml | 2 +-
command.md | 11 +++++++++++
wit/exit.wit | 2 +-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 2fcc3b3..ecc71c4 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -22,4 +22,4 @@ jobs:
with:
wit-bindgen: '0.28.0'
worlds: 'command imports'
- features: 'exit-with-code'
+ features: 'cli-exit-with-code'
diff --git a/command.md b/command.md
index cdd51c1..5e5fe2a 100644
--- a/command.md
+++ b/command.md
@@ -73,6 +73,17 @@ directory, interpreting . as shorthand for this.
+exit-with-code: func
+Exit the current instance and any linked instances, reporting the
+specified status code to the host.
+The meaning of the code depends on the context, with 0 usually meaning
+"success", and other values indicating various types of failure.
+This function does not return; the effect is analogous to a trap, but
+without the connotation that something bad has happened.
+Params
+
Import interface wasi:io/error@0.2.0
Types
diff --git a/wit/exit.wit b/wit/exit.wit
index 2c28658..427935c 100644
--- a/wit/exit.wit
+++ b/wit/exit.wit
@@ -12,6 +12,6 @@ interface exit {
///
/// This function does not return; the effect is analogous to a trap, but
/// without the connotation that something bad has happened.
- @unstable(feature = exit-with-code)
+ @unstable(feature = cli-exit-with-code)
exit-with-code: func(status-code: u8);
}
From 6b20b70f59fddf7f1b0ccfc772afb913218de20d Mon Sep 17 00:00:00 2001
From: Bailey Hayes
Date: Thu, 1 Aug 2024 11:39:52 -0400
Subject: [PATCH 6/6] chore: regen imports
---
imports.md | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/imports.md b/imports.md
index 93e32c3..495ad20 100644
--- a/imports.md
+++ b/imports.md
@@ -68,6 +68,17 @@ directory, interpreting . as shorthand for this.
+exit-with-code: func
+Exit the current instance and any linked instances, reporting the
+specified status code to the host.
+The meaning of the code depends on the context, with 0 usually meaning
+"success", and other values indicating various types of failure.
+This function does not return; the effect is analogous to a trap, but
+without the connotation that something bad has happened.
+Params
+
Import interface wasi:io/error@0.2.0
Types