Skip to main content

start_command/
mod.rs

1//! start-command library
2//!
3//! Provides command execution with isolation, substitution, and failure handling.
4
5pub mod args_parser;
6pub mod args_parser_queries;
7mod atomic_write;
8pub mod attached_diagnostics;
9pub mod cgroup_memory;
10pub mod cpu_penalty;
11pub mod cpu_penalty_monitor;
12pub mod detached_finalize;
13pub mod detached_output;
14pub(crate) mod docker_cleanup;
15mod docker_network_lifecycle;
16pub mod docker_post_mortem;
17pub mod docker_recovery_options;
18pub mod docker_resource_limits;
19pub mod docker_resource_options;
20pub mod execution_attach;
21pub mod execution_attempt;
22pub mod execution_control;
23pub mod execution_recovery;
24pub mod execution_resume;
25pub mod execution_resume_all;
26pub mod execution_store;
27pub mod exit_evidence;
28pub mod exit_reason;
29pub mod failure_handler;
30pub mod isolation;
31pub mod isolation_metadata;
32pub mod launch_owner;
33pub mod log_uploader;
34pub mod output_blocks;
35pub mod query_commands;
36pub mod recovery_delay;
37pub mod resume_resources;
38pub mod sequence_parser;
39pub mod session_probe;
40pub mod signal_handler;
41pub mod status_footer;
42pub mod status_formatter;
43pub mod status_probe;
44pub mod store_lock;
45pub mod substitution;
46pub mod usage;
47pub mod user_manager;
48
49mod lino_value_json;
50mod local_hostname;
51
52// Re-export commonly used items
53pub use args_parser::{
54    generate_session_name, generate_uuid, get_effective_mode, has_isolation, is_valid_uuid,
55    parse_args, validate_options, ParsedArgs, WrapperOptions, VALID_BACKENDS, VALID_OUTPUT_FORMATS,
56    VALID_SHELLS,
57};
58pub use detached_finalize::{
59    build_detached_finalize_snippet, finalize_detached_execution, reconcile_finalized_record,
60    run_internal_finalize, DetachedFinalizeFacts, FinalizeOutcome,
61    END_TIME_SOURCE_DOCKER_FINISHED_AT, END_TIME_SOURCE_LOG_FOOTER, END_TIME_SOURCE_OBSERVED_AT,
62    INTERNAL_FINALIZE_FLAG, WATCHER_LOST_CONTAINER,
63};
64pub use docker_cleanup::{
65    build_detached_docker_completion_script, build_detached_docker_completion_script_with,
66    docker_command, DockerContainerCleanupPolicy, DockerWatcherOptions,
67};
68pub use docker_post_mortem::{
69    build_docker_post_mortem_snippet, build_docker_removal_note_snippet,
70    build_docker_running_condition, build_docker_state_snippet,
71    build_docker_still_running_note_snippet, build_docker_wait_for_exit_snippet,
72    format_container_post_mortem, format_container_removal_note, format_lifetime,
73    normalize_docker_timestamp, ContainerPostMortem, DOCKER_RUNNING_INSPECT_FORMAT,
74    DOCKER_STATE_INSPECT_FORMAT, DOCKER_ZERO_TIME, LOG_CAPTURE_STOPPED_NOTE, POST_MORTEM_HEADER,
75    STILL_RUNNING_NOTE,
76};
77pub use execution_attach::{
78    attach_execution, attach_execution_with_runners, build_attach_plan,
79    format_attach_result_as_links_notation, AttachPlan, AttachResultFields, ExecutionAttachResult,
80    InteractiveRunner, SystemInteractiveRunner,
81};
82pub use execution_control::{
83    collect_descendant_pids, collect_descendant_pids_with_runner, collect_process_ids,
84    collect_process_ids_with_runner, control_execution, control_execution_with_runner,
85    format_control_result_as_links_notation, get_control_command, parse_screen_pid,
86    CommandRunOutput, CommandRunner, ControlAction, ControlCommand, ExecutionControlResult,
87    SystemCommandRunner,
88};
89pub use execution_resume::{
90    build_resume_plan, build_resumed_session_name, build_snapshot_image_name, resume_execution,
91    resume_execution_with, ExecutionResumeResult, ResumeHooks, ResumeMode, ResumePlan,
92    ResumeResultFields, SystemResumeHooks,
93};
94pub use execution_resume_all::{
95    format_resume_all, resume_all_executions, resume_all_executions_with, ExecutionResumeAllResult,
96    ResumeAllAction, ResumeAllEntry,
97};
98pub use execution_store::{
99    is_clink_installed, CleanupOptions, CleanupResult, ExecutionRecord, ExecutionRecordOptions,
100    ExecutionStats, ExecutionStatus, ExecutionStore, ExecutionStoreOptions,
101};
102pub use exit_reason::{
103    describe_exit_code, describe_exit_code_str, detect_exit_reason, resolve_exit_reason,
104    signal_name_for_exit_code, ExitCodeDescription,
105};
106pub use failure_handler::{handle_failure, Config as FailureConfig};
107pub use isolation::{
108    append_log_file, build_command_string, build_command_string_with, build_display_command,
109    build_shell_with_args_cmd_args, command_name, create_log_footer, create_log_header,
110    create_log_path, create_log_path_for_execution, docker_image_exists, docker_pull_image,
111    get_default_docker_image, get_timestamp, is_command_available, is_interactive_shell_command,
112    is_shell_invocation_with_args, quote_shell_arg, quote_shell_arg_with, run_as_isolated_user,
113    run_isolated, split_shell_words, split_shell_words_with, to_shell_words, write_log_file,
114    IsolationOptions, IsolationResult, LogHeaderParams, ShellQuotingStyle,
115};
116pub use isolation_metadata::{
117    build_isolation_options_map, docker_runtime_metadata, docker_runtime_status_lines,
118    docker_runtime_status_lines_for_options,
119};
120pub use log_uploader::upload_execution_log;
121#[allow(deprecated)]
122pub use output_blocks::{
123    // Timeline format API (formerly "status spine")
124    create_command_line,
125    create_empty_spine_line, // deprecated, use create_empty_timeline_line
126    create_empty_timeline_line,
127    create_finish_block,
128    create_spine_line, // deprecated, use create_timeline_line
129    create_start_block,
130    create_timeline_line,
131    create_timeline_separator,
132    create_virtual_command_block,
133    create_virtual_command_result,
134    escape_for_links_notation,
135    format_duration,
136    format_value_for_links_notation,
137    generate_isolation_lines,
138    get_result_marker,
139    parse_isolation_metadata,
140    FinishBlockOptions,
141    IsolationMetadata,
142    StartBlockOptions,
143    FAILURE_MARKER,
144    SPINE, // deprecated, use TIMELINE_MARKER
145    SUCCESS_MARKER,
146    TIMELINE_MARKER,
147};
148pub use query_commands::{dispatch_query_command, handle_cleanup, report_result, QueryOutcome};
149pub use session_probe::{probe_session, SessionProbe, SessionState};
150pub use signal_handler::{
151    clear_current_execution, get_signal_exit_code, set_current_execution, setup_signal_handlers,
152    was_signal_received,
153};
154pub use status_footer::{
155    parse_footer_from_tail, parse_footer_timestamp, read_footer_from_log, LogFooter,
156};
157pub use status_formatter::{
158    attach_current_time, enrich_detached_status, format_record, format_record_as_links_notation,
159    format_record_as_links_notation_with_current_time, format_record_as_text,
160    format_record_as_text_with_current_time, format_record_list,
161    format_record_list_as_links_notation, format_record_list_as_text,
162    format_record_with_current_time, list_executions, list_executions_filtered, query_status,
163    read_exit_code_from_log, StatusQueryResult,
164};
165pub use status_probe::is_detached_session_alive;
166pub use substitution::{process_command, ProcessOptions, SubstitutionResult};
167pub use usage::print_usage;
168pub use user_manager::{
169    create_isolated_user, delete_user, get_current_user, get_current_user_groups, has_sudo_access,
170    CreateIsolatedUserOptions, DeleteUserOptions, UserOperationResult,
171};