Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add get_cli_args support for native #85

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moonbitlang/x",
"version": "0.4.15",
"version": "0.4.16",
"readme": "README.md",
"repository": "https://github.com/moonbitlang/x",
"license": "Apache-2.0",
Expand Down
3 changes: 2 additions & 1 deletion sys/internal/ffi/moon.pkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"import": [
"moonbitlang/x/internal/ffi"
"moonbitlang/x/internal/ffi",
"moonbitlang/x/encoding"
],
"targets": {
"sys_wasm.mbt": ["wasm", "wasm-gc"],
Expand Down
12 changes: 10 additions & 2 deletions sys/internal/ffi/sys_native.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

///|
fn internal_get_cli_args() -> FixedArray[Bytes] = "$moonbit.get_cli_args"

///|
pub fn get_cli_args() -> Array[String] {
// not implement yet
panic()
Array::from_fixed_array(
internal_get_cli_args().map(fn {
// Here we assume that the CLI arguments are encoded in well-formed UTF-8.
// TODO: Handle other encodings.
arg => @encoding.decode_strict(UTF8, arg).to_string?().unwrap()
}),
)
}

///|
Expand Down
Loading