use std::{io, os::unix::process::CommandExt, process::Command};
use {clap::Args, thiserror::Error};
#[derive(Debug, Error)]
pub enum ShellError {
#[error("failed to access the USERNAME environment variable: {0}")]
Username(#[source] std::env::VarError),
#[error("failed to execute the login shell: {0}")]
Execute(#[source] io::Error),
}
#[derive(Args)]
pub struct Arguments {}
pub fn run(_args: Arguments) -> Result<(), ShellError> {
let username = std::env::var("USERNAME").map_err(ShellError::Username)?;
Err(ShellError::Execute(
Command::new("sudo")
.arg("-H")
.arg("-i")
.arg("-u")
.arg(&username)
.exec(),
))
}