Skip to main content

run

Function run 

Source
pub fn run(
    src: &str,
    project_dir: Option<&Path>,
    json: bool,
    flags: &CliPolicyFlags,
) -> CmdOutput
Expand description

Validate src and return formatted output.

When project_dir is Some (the .zen file’s parent directory), each declared asset’s file is checked for existence and a hard asset.missing Error diagnostic is added for any that are absent, and that directory is the starting point for the local .zenith.kdl config walk-up. When None, no asset files are checked and no local config is discovered.

The effective diagnostic policy is merge_policy(global, local, in_file, flags) — global/local config plus the document’s own diagnostics block plus the --allow/--warn/--deny flags — applied once via validate_with_policy. With no config files and no flags the merged policy is identical to the document’s in-file policy, so output is unchanged.

  • Parse errors and config-load errors produce exit_code = 2.
  • Documents with at least one error-severity diagnostic produce exit_code = 1.
  • Clean documents produce exit_code = 0.