shine-cli 2.1.0

Give personal automation a reviewable lifecycle
Documentation
//! CLI-only administrator helpers for self-installation.

use anyhow::Result;
use std::io::IsTerminal;

pub(crate) async fn admin_lock() -> Result<shine_core::runtime::PrivilegedOperationGuard> {
    use shine_core::runtime::PrivilegedFileSystemHost;
    shine_core::runtime::RealHost
        .acquire_privileged_operation()
        .await
}

/// Builds a sudo command which fails fast rather than prompting without a TTY.
pub(crate) fn sudo_command() -> tokio::process::Command {
    let mut command = tokio::process::Command::new("sudo");
    if !std::io::stdin().is_terminal() {
        command.arg("-n");
    }
    command
}