pub(crate) fn machine_queue_validate_command() -> &'static str {
"cueloop machine queue validate"
}
pub(crate) fn machine_queue_graph_command() -> &'static str {
"cueloop machine queue graph"
}
pub(crate) fn machine_queue_repair_command(dry_run: bool) -> &'static str {
if dry_run {
"cueloop machine queue repair --dry-run"
} else {
"cueloop machine queue repair"
}
}
pub(crate) fn machine_queue_undo_dry_run_command() -> &'static str {
"cueloop machine queue undo --dry-run"
}
pub(crate) fn machine_queue_undo_restore_command() -> &'static str {
"cueloop machine queue undo --id <SNAPSHOT_ID>"
}
pub(crate) fn machine_task_mutate_command(dry_run: bool) -> &'static str {
if dry_run {
"cueloop machine task mutate --dry-run --input <PATH>"
} else {
"cueloop machine task mutate --input <PATH>"
}
}
pub(crate) fn machine_task_build_command() -> &'static str {
"cueloop machine task build --input <PATH>"
}
pub(crate) fn task_decompose_write_preview_command(checkpoint_id: &str) -> String {
format!(
"cueloop task decompose --from-preview {} --write",
shell_quote(checkpoint_id)
)
}
pub(crate) fn machine_task_decompose_write_preview_command(checkpoint_id: &str) -> String {
format!(
"cueloop machine task decompose --from-preview {} --write",
shell_quote(checkpoint_id)
)
}
fn shell_quote(value: &str) -> String {
if value.bytes().all(|byte| {
byte.is_ascii_alphanumeric() || matches!(byte, b'-' | b'_' | b'.' | b'/' | b':')
}) {
return value.to_string();
}
format!("'{}'", value.replace('\'', "'\\''"))
}
pub(crate) fn machine_run_one_resume_command() -> &'static str {
"cueloop machine run one --resume"
}
pub(crate) fn machine_run_stop_command(dry_run: bool) -> &'static str {
if dry_run {
"cueloop machine run stop --dry-run"
} else {
"cueloop machine run stop"
}
}
pub(crate) fn machine_run_parallel_status_command() -> &'static str {
"cueloop machine run parallel-status"
}
pub(crate) fn machine_run_loop_command(parallel: bool, force: bool) -> &'static str {
match (parallel, force) {
(true, false) => "cueloop machine run loop --resume --max-tasks 0 --parallel <N>",
(true, true) => "cueloop machine run loop --resume --max-tasks 0 --force --parallel <N>",
(false, false) => "cueloop machine run loop --resume --max-tasks 0",
(false, true) => "cueloop machine run loop --resume --max-tasks 0 --force",
}
}
pub(crate) fn machine_doctor_report_command() -> &'static str {
"cueloop machine doctor report"
}