# step-nickel-export.ncl — reusable ActionStep template for `nickel export`.
#
# Usage in a mode:
#   let t = import "../../reflection/templates/step-nickel-export.ncl" in
#   steps = [
#     t { id = "export-core", file = ".ontology/core.ncl" },
#     t { id = "export-state", file = ".ontology/state.ncl", import_path = "ontology/defaults" },
#   ]
#
# Required params: id (String), file (String)
# Optional params: import_path, action, actor, depends_on, on_error

fun params =>
  let defaults = {
    import_path | default = "ontology/defaults",
    action      | default = "Export Nickel file and validate the result against its contracts.",
    actor       | default = 'Both,
    depends_on  | default = [],
    on_error    | default = { strategy = 'Stop },
  } in
  let p = defaults & params in
  {
    id         = p.id,
    action     = p.action,
    cmd        = "nickel export --import-path %{p.import_path} %{p.file}",
    actor      = p.actor,
    depends_on = p.depends_on,
    on_error   = p.on_error,
  }
