deislabs / wagi

Write HTTP handlers in WebAssembly with a minimal amount of work
Apache License 2.0
884 stars 45 forks source link

Rationalise Wasm module source options #144

Closed itowlson closed 2 years ago

itowlson commented 2 years ago

This is a breaking change to the CLI. Under the new rules:

The resulting behaviour is:

# Didn't pass anything - NOW AN ERROR, no longer defaults to ./modules.toml
13:01 $ ./target/debug/wagi 
error: The following required arguments were not provided:
    <--config <MODULES_TOML>|--bindle <BINDLE_ID>>

USAGE:
    wagi [OPTIONS] <--config <MODULES_TOML>|--bindle <BINDLE_ID>>

# --------------------------------------------------------------------------------

# Passed module file only - HAPPY PATH
13:01 $ ./target/debug/wagi -c foo.toml

# --------------------------------------------------------------------------------

# Passed a module file and bindle ID - STILL AN ERROR, new message
13:01 $ ./target/debug/wagi -b foo/1.2.3 -c foo.toml
error: The argument '--config <MODULES_TOML>' cannot be used with one or more of the other specified arguments

USAGE:
    wagi <--bindle-path <bindle_path>|--bindle-url <BINDLE_URL>> <--config <MODULES_TOML>|--bindle <BINDLE_ID>>

# --------------------------------------------------------------------------------

# Passed both a module file and bindle directory - STILL AN ERROR though the message is a bit misleading
13:04 $ ./target/debug/wagi -c foo.toml --bindle-path foo
error: The following required arguments were not provided:
    --bindle <BINDLE_ID>
    <--bindle-path <bindle_path>|--bindle-url <BINDLE_URL>>

USAGE:
    wagi <--bindle-path <bindle_path>|--bindle-url <BINDLE_URL>> <--config <MODULES_TOML>|--bindle <BINDLE_ID>>

# --------------------------------------------------------------------------------

# Passed both a module file and bindle URL - NOW ALLOWED
13:05 $ ./target/debug/wagi -c foo.toml --bindle-url foo

# --------------------------------------------------------------------------------

# Passed only a bindle ID - NOW AN ERROR, no longer defaults server URL
13:01 $ ./target/debug/wagi -b foo/1.2.3
error: The following required arguments were not provided:
    <--bindle-path <bindle_path>|--bindle-url <BINDLE_URL>>

USAGE:
    wagi <--bindle-path <bindle_path>|--bindle-url <BINDLE_URL>> <--config <MODULES_TOML>|--bindle <BINDLE_ID>>

# --------------------------------------------------------------------------------

# Passed bindle ID and standalone directory - HAPPY PATH
13:02 $ ./target/debug/wagi -b foo/1.2.3 --bindle-path foo

# --------------------------------------------------------------------------------

# Passed bindle ID and server URL - HAPPY PATH
13:04 $ ./target/debug/wagi -b foo/1.2.3 --bindle-url foo

# --------------------------------------------------------------------------------

# Passed bindle ID and standalone directory *and* server URL - STILL AN ERROR, new message
13:04 $ ./target/debug/wagi -b foo/1.2.3 --bindle-path foo --bindle-url foo
error: The argument '--bindle-path <bindle_path>' cannot be used with one or more of the other specified arguments

USAGE:
    wagi <--bindle-path <bindle_path>|--bindle-url <BINDLE_URL>> <--config <MODULES_TOML>|--bindle <BINDLE_ID>>