Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Allow developers to specify a package's entrypoint command #15

Closed
Michael-F-Bryan opened this issue Jul 20, 2023 · 2 comments · Fixed by #17 or #18
Closed

Allow developers to specify a package's entrypoint command #15

Michael-F-Bryan opened this issue Jul 20, 2023 · 2 comments · Fixed by #17 or #18

Comments

@Michael-F-Bryan
Copy link
Contributor

The wasmer.toml format doesn't give package developers a way to specify the entrypoint command, so code turning it into a webc manifest has to guess:

/// Infer the package's entrypoint.
///
/// there is no way to explicitly specify an entrypoint in a
/// `wasmer.toml` file. If there is exactly one command, we'll use that,
/// otherwise the entrypoint will be left unspecified.
fn entrypoint(manifest: &WasmerManifest) -> Option<String> {
    match manifest.command.as_deref() {
        Some([only_command]) => Some(only_command.get_name()),
        _ => None,
    }
}

We should allow package developers to specify the entrypoint so downstream users don't need to do wasmer run my/package --command=some-command every time.

Possible Syntax

Given a package with multiple commands, there are a couple different ways the entrypoint could be specified.

Option 1 - put it in [package]

[package]
name = "sharrattj/bash"
version = "1.2.3"
entrypoint = "bash"

[[module]]
name = "bash"
source = "./bash.wasm"
abi = "wasi"

[[command]]
name = "bash"
module = "bash"

[[command]]
name = "sh"
module = "bash"

Option 2 - put it in the command

[package]
name = "sharrattj/bash"
version = "1.2.3"

[[module]]
name = "bash"
source = "./bash.wasm"
abi = "wasi"

[[command]]
name = "bash"
module = "bash"
entrypoint = true

[[command]]
name = "sh"
module = "bash"

Option 3 - create a separate section

[package]
name = "sharrattj/bash"
version = "1.2.3"

[[module]]
name = "bash"
source = "./bash.wasm"
abi = "wasi"

[[command]]
name = "bash"
module = "bash"

[[command]]
name = "sh"
module = "bash"

[defaults]
entrypoint = "bash"
@syrusakbary
Copy link
Member

Option 1: simplest and it does the job
Option 2: we would need to do extra checks to make sure there's only one command with entrypoint = True
Option 3: it's more cumbersome that option 1

Option 1 plz :)

@ptitSeb
Copy link

ptitSeb commented Jul 20, 2023

Yeah, option 1 seems the more practicle. Simple and efficient.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants