#cli

    The command table behind fus: argument parsing, help text and dispatch.

    Import as justjavac/fus/cli.

    parse_command(argv) maps argv to a Command (Build, Run, Serve, Check, Init, Clean, Help, Version, Unknown); argv[0] is the program name, so ["fus", "check"] is a check and ["fus"] builds the current directory. parse_options(args, options) folds --root, --dest, --config, --port, --force, --drafts and -q into BuildOptions plus a port.

    dispatch(argv) runs the command and returns an Outcome: Done, Fail, or Serve(name, options, port) for the two commands that need the HTTP server. Keeping the table in a library rather than in main is what lets tests and embedders drive the CLI without starting a process.

    init_site(root) writes the sample site, build_command and check_command print the summaries, and clean_site(options, scope) deletes output and/or cache. All of them are re-exported by justjavac/fus.

    CleanScope

    pub(all) enum CleanScope {
    OutputOnly
    CacheOnly
    OutputAndCache
    } derive(Eq)

    What clean should delete.

    OutputAndCache is the default; the narrower scopes exist for CI jobs that want to keep the incremental cache between builds.

    Command

    A parsed top-level CLI command.

    dispatch turns one of these into an Outcome, which is all main needs.

    Outcome

    pub(all) enum Outcome {
    Done
    Fail
    Serve(String,
    BuildOptions
    , Int)
    }

    What the executable should do after the shared dispatch has run.

    serve and run need the HTTP server, which lives in its own package, so dispatch hands them back to the caller instead of running them.

    build_command

    async fn build_command(options :
    BuildOptions
    ) -> Unit

    Build a site and print the summary unless quiet mode is requested.

    check_command

    async fn check_command(options :
    BuildOptions
    ) -> Bool

    Validate a site and print every finding.

    Returns true when no errors were found. Warnings do not fail the check, so this suits a CI gate while leaving room for non-fatal notes.

    clean_site

    async fn clean_site(options :
    BuildOptions
    , scope : CleanScope) -> Bool

    Remove generated output, the incremental cache, or both.

    Paths come from the loaded configuration, so --root alone is enough even when the site writes to a custom dest. Content files are never touched. Returns false, without deleting anything, when the output resolves to the site root: dest: . or a .. segment would otherwise erase the sources.

    dispatch

    async fn dispatch(args : Array[String]) -> Outcome

    Run one command from the process arguments.

    This is the single place that knows how a command maps to an action, so the main only has to start the server when this returns Serve.

    help

    fn help(topic? : String?) -> Unit

    Print the command list, or the usage of one command when topic is set.

    init_site

    async fn init_site(root : String) -> Unit

    Scaffold a complete example site at root.

    parse_command

    fn parse_command(args : Array[String]) -> Command

    Parse argv into a command for the caller to execute.

    argv[0] is the program name, as in @env.args(); the subcommand is argv[1]. An argv with no subcommand builds the current directory, so parse_command(["fus"]) is the same as parse_command(["fus", "build"]). Passing subcommand arguments without the program name (["check"]) builds instead, because check lands in the program-name slot.

    parse_options

    Parse global options after the command name.

    Returns the resulting build options and the requested HTTP port. Unknown tokens are ignored so that subcommands can grow without breaking callers.
    fn print_version() -> Unit

    Print the tool version line.

    Source Files