Contents

Supercharging the Coni CLI with Embedded Subcommands

One of the greatest strengths of the Coni language is its portability. We designed it so that the core interpreter and standard libraries are shipped as a single, static binary. You don’t need a bloated installation process; you just download the executable and you’re good to go.

However, as the ecosystem grew—like the addition of our Android build pipeline—we found ourselves with a minor workflow annoyance. To invoke the Android APK builder, you had to run the script via its absolute path:

coni libs/android/bin/build-apk.coni ./my-app

While functional, it didn’t feel native. We wanted a polished developer experience where developers could simply run:

coni android build-apk ./my-app

Today, we’re thrilled to announce that we’ve bridged this gap by implementing Dynamic Subcommand Routing powered by Go’s embed filesystem!

How It Works

We made three crucial architectural changes to the Go compiler:

1. Embedding the Binaries

We expanded the //go:embed directives inside our Go compiler to automatically package all bin/ directories across all modules:

//go:embed libs/*/src libs/*/bin
var embeddedLibs embed.FS

This simple change guarantees that helper scripts (like build-apk.coni) are permanently baked into the executable.

2. The Subcommand Interceptor

We introduced a clever interceptor in the CLI argument parsing logic. Now, if you run an unrecognized command like coni android build-apk, the parser intercepts it and dynamically constructs a path query: libs/android/bin/build-apk.coni.

It checks the embedded filesystem, and if the script exists, it dynamically reroutes the execution directly to the embedded payload!

3. Argument Masking

The final piece of the puzzle was preserving the illusion for the script itself. The build-apk.coni script uses cli/parse-opts to read flags (like -p camera). If we blindly passed the arguments to the evaluator, the script would get confused by the leading android and build-apk tokens.

To solve this, the Go router rewrites the global os.Args slice behind the scenes:

os.Args = append([]string{os.Args[0], embeddedPath}, os.Args[3:]...)

From the script’s perspective, it thinks it was invoked directly!

The Result

The result is a lightning-fast, seamless CLI experience. All tooling and helper scripts are shipped organically within the Coni binary, accessible instantly through natural, native-feeling subcommands.

No extra downloads, no path configurations. Just pure, unadulterated productivity!