hotg-ai / rune

Rune provides containers to encapsulate and deploy edgeML pipelines and applications
Apache License 2.0
133 stars 15 forks source link

Split the rune CLI up so there are individual binaries for each sub-command #357

Open Michael-F-Bryan opened 2 years ago

Michael-F-Bryan commented 2 years ago

A suggestion @f0rodo mentioned is being able to split rune run out of the rune CLI to simplify the process of installing from source.

One possible way we could implement this is by creating multiple sub-commands, taking inspiration from how Cargo does custom subcommands.

We can then use the required-features field in Cargo.toml to make sure a particular subcommand is only installed when running cargo install with the corresponding feature flag.

For example:

# crates/rune-cli/Cargo.toml
[package]
name = "hotg-rune-cli"

[[bin]]
name = "rune"
path = "src/bin/rune.rs"

[[bin]]
name = "rune-run"
path = "src/bin/rune-run.rs"
required-features = ["run"]

[[bin]]
name = "rune-build"
path = "src/bin/rune-build.rs"
required-features = ["build"]

...

[features]
default = ["run", "build", "..."]
# Subcommands
run = []
build = []
# Normal feature flags for altering behaviour
wasmer-runtime = ["wasmer", "run"]
wasm3-runtime = ["wasm3", "run"]

That way you can run cargo install hotg-rune-cli to get rune run and rune build, or you could choose to just get rune build by using cargo install hotg-rune-cli --no-default-features --features build.