moui_cli

    Standalone project generator and environment doctor for MoUI

    moui
    cli
    generator
    doctor
    mobile-build
    build
    run
    verify
    Download zip
    Author
    Version
    0.6.2
    License
    Apache-2.0
    Last updated
    10 hours ago
    Downloads
    456

    #MoUI CLI

    moui creates and operates independent MoUI projects. Desktop and web targets build and run directly from the project directory; mobile targets use the matching wzzc-dev/window host template and *_window_hosted entrypoint, so the CLI does not create a separate mobile runtime layer.

    #Commands

    CommandPurpose
    moui new <target>Create an independent project.
    moui add platform <platform>Add a desktop, web, or mobile platform.
    moui doctorCheck selected platform toolchains.
    moui package [platform] [app]Package a desktop/web app as a distributable (macOS .app, Windows portable folder, web bundle); without positional arguments, print the release-planning inventory.
    moui dev [package]Build, watch, restart, and serve a project during development.
    moui test [package]Run a project's MoonBit tests (defaults to the app package).
    moui inspectRead the latest DevTools document published by moui dev --inspect.
    moui build <platform> <app>Build an artifact for any platform: desktop/web build the entrypoint package in place; Android / iOS / HarmonyOS produce APK / .app / .hap.
    moui run <platform> <app>Run an app: desktop builds and launches in place, web serves through the dev runner, mobile builds, installs, and launches on a device or emulator.
    moui screenshot [project]Render an app to a PNG through an offscreen renderer; no window or display is opened.
    moui devicesList connected mobile devices, emulators, and the desktop host.
    moui verify <platform> <app>Verify generated embedded-runtime evidence.
    moui config <action>Read or update CLI configuration.

    Use moui --help or moui <command> --help for current options.

    #Run Desktop And Web

    moui run macos . # build + launch the native executable moui run windows . # MSVC environment is configured automatically moui run linux . moui run web . # serve through the dev runner (refresh + error overlay)

    Package distributables:

    moui package macos . # dist/macos/<Name>.app moui package windows . # dist/windows/<Name>/ with exe + run.cmd moui package linux . # dist/linux/<Name>/ with binary + run.sh + .desktop moui package web . # static web bundle (gzip/brotli + bundle-size.json)

    moui package builds a release artifact by default; pass --debug to inspect a debug build. Packaging runs on the matching host for macOS/Windows/Linux (use --allow-cross only when the build output is known to match the target). macOS accepts --icon PATH to copy an .icns into Contents/Resources and write CFBundleIconFile + PkgInfo. Windows copies icudtl.dat from the Skia release cache when it is available. Web writes moui-package.json beside the bundle metadata; when the repo-local package-web-app.mjs is absent (a generated project), the CLI falls back to its built-in flat bundle packager. Linux run/build also work directly (moui run linux .). Windows builds resolve the MSVC toolchain through vswhere and vcvarsall in-process, so sourcing scripts/windows/msvc_env.ps1 first is no longer required (a preset CC environment is respected).

    #Capture A Screenshot

    moui screenshot mounts the app package's program() in an offscreen runtime, paints one frame through Skia (or Sun), and writes a PNG. It never opens a window, so it works over SSH and in CI on a host that can build the project.

    moui screenshot . --out gallery.png moui screenshot examples/gallery --width 1080 --height 820 --scale 2 moui screenshot . --scheme dark --renderer sun --json

    The project's app package must expose pub fn program() -> @moui.Program[Model, Msg] (the moui new templates do). The renderer dependency must already be in the project module: moui new desktop projects include wzzc-dev/moui_skia_renderer; --renderer sun needs wzzc-dev/moui_sun_renderer.

    Options: --app PACKAGE (default app), --out PATH (default moui-screenshot.png), --width/--height (logical DIPs, default 1080x720), --scale (default 2.0), --scheme light|dark|system (runtime environment only; apps that pin their own theme ignore it), --renderer skia|sun, and --keep-temp for debugging the generated render package.

    The command writes a temporary moui_screenshot_tmp package inside the project module, runs it with moon, and removes it afterwards. The PNG contains MoUI's painted content only: native window chrome, WebViews, and platform child views are not part of the offscreen frame.

    #Develop With A Watch Loop

    From a generated project, run a one-shot build with moui dev --once. Without --once, native packages are rebuilt and restarted after source changes. Web packages use --web (or infer it from web_wasm) and serve the project at http://127.0.0.1:3000/; successful rebuilds refresh the page and failed builds appear in the injected error overlay while the watcher keeps running. Use --interval-ms, --port, and --state PATH to tune the loop.

    The --state path is passed to the app as MOUI_DEV_STATE_FILE for optional file-based model handoff during a restart. V1 restarts processes and does not preserve in-process runtime state.

    Pass --inspect to publish a read-only DevTools document at .moui/devtools.json; moui inspect prints it, and the Web dev server exposes /__moui/devtools plus its JSON endpoint. On native hosts the app also opens a loopback DevTools socket and writes its port to .moui/devtools.port; moui inspect --port <port> --method snapshot|trace|diagnostics queries it directly (the file remains the fallback when a socket is unavailable).

    #Create A Project

    moon install wzzc-dev/moui_cli/cmd/moui moui new my_app --platform android --bundle-id dev.example.myapp cd my_app moon update moon check

    Mobile project generation creates moui.mobile.json and an android_window_hosted, ios_window_hosted, or harmonyos_window_hosted package. Application code remains in app/.

    #Build Mobile Targets

    moui.mobile.json holds the application id, display name, shared app package, and platform-specific identifiers. Build from the application workspace:

    moui build android my_app --mobile-config "$PWD/moui.mobile.json" moui build ios my_app --mobile-config "$PWD/moui.mobile.json" moui build harmonyos my_app --mobile-config "$PWD/moui.mobile.json"

    Add --release to select the release variant where the platform builder owns it: Android runs assembleRelease (and picks app-release.apk or the unsigned fallback), iOS compiles with -O2. Android release signing reads MOUI_ANDROID_KEYSTORE, MOUI_ANDROID_KEYSTORE_PASSWORD, MOUI_ANDROID_KEY_ALIAS, and MOUI_ANDROID_KEY_PASSWORD from the environment and injects a Gradle signing config; without a keystore the build stays unsigned. iOS device builds take --signing-identity, --provisioning-profile, and optional --entitlements; the CLI embeds the profile and runs codesign. Signing/notarization and store packaging remain host-required; --prepare-only generates inputs without invoking Gradle, Xcode, or hvigor. --fallback-skia is packaging-only evidence and does not promote a runtime support claim. The physical-device runbook lives in docs/mobile-device-evidence.md.

    #Validate Hosts

    moui doctor --platform android moui devices --platform android moui run android my_app --mobile-config "$PWD/moui.mobile.json"

    The platform template owns lifecycle, surface creation, and input. MoUI's backend supplies the app runtime and renderer provider through the window event loop.

    CliOutcome

    pub(all) struct CliOutcome {
    exit_code : Int
    stdout : String
    stderr : String
    }

    run_cli

    fn run_cli(args : Array[String], cwd : String) -> CliOutcome