Skip to main content

Module runner

Module runner 

Source
Expand description

Step runner — the engine behind [[command]] and [[hook]] execution.

This module executes a Vec<Step> declaratively, with injected dependencies for process execution, desktop notification, and user prompting. Every downstream feature that needs to run user-defined steps (post-update hooks #43, krypt menu #25, krypt <group> <name> #25) delegates here.

§Predicate evaluator (stub)

The eval_predicate parameter is a stub for issue #24. All predicate strings currently evaluate to true (no-op). Issue #24 will implement the real grammar: command_exists:foo, platform:linux, env:FOO=bar, !file_exists:/path, and so on. Tests that need predicate gating supply their own closure.

§on_fail semantics

valuebehaviour
abort (default)bubble up RunnerError::NonZeroExit
ignoreswallow, increment steps_failed_ignored
notifycall Notifier with failure details, then abort
promptask Prompter; true → ignore, false → abort

ignore_failure = true is a shortcut alias for on_fail = "ignore" and wins over a conflicting on_fail = "abort" if both are present (with a tracing::warn!).

§Cross-platform note

RealProcessExec wraps std::process::Command directly. No shell is injected — run = ["echo", "hi"] must reference a real binary in PATH. Shell builtins (e.g. echo on Windows outside Git Bash) are the caller’s responsibility. Path-containing args are passed through unchanged.

AutoNotifier auto-detects the best notification backend at construction. Pin crate::notify::NotifyBackend::Stderr in tests.

Re-exports§

pub use crate::notify::AutoNotifier;

Structs§

Context
Execution context threaded through all steps.
MockNotifier
Mock notifier that records calls.
MockProcessExec
Mock process executor with scripted responses.
MockPrompter
Mock prompter with scripted boolean responses.
ProcessResult
Outcome of a single process execution.
RealProcessExec
Production process executor using std::process::Command.
RealPrompter
Interactive prompter backed by stdin readline.
RunReport
Summary of a completed step sequence.

Enums§

RunnerError
Anything that can go wrong while running steps.

Traits§

Notifier
Abstraction over desktop notification, allowing test mocks.
ProcessExec
Abstraction over process spawning, allowing test mocks.
Prompter
Abstraction over interactive prompting, allowing test mocks.

Functions§

execute_command
Execute a KryptCommand as a step sequence.
execute_hook
Execute a Hook as a single-step equivalent.
execute_steps
Execute a slice of steps with the given execution context and injected dependencies.
interpolate
Interpolate {name}, {0}..{9}, {stdin}, and {{/}} escapes.