use lmrc_ssh::{AuthMethod, SshClient};

fn main() -> Result<(), lmrc_ssh::Error> {
    println!("SSH Manager - Simple Connection Example\n");

    // Replace these with your actual SSH server details
    let host = std::env::var("SSH_HOST").unwrap_or_else(|_| "example.com".to_string());
    let username = std::env::var("SSH_USER").unwrap_or_else(|_| "user".to_string());
    let password = std::env::var("SSH_PASSWORD").unwrap_or_else(|_| "password".to_string());

    println!("Connecting to {}@{}", username, host);

    let mut client = SshClient::new(host, 22)?
        .with_auth(AuthMethod::Password {
            username: username.clone(),
            password,
        })
        .connect()?;

    println!("✓ Connected successfully!\n");

    // Execute a simple command
    println!("Executing: whoami");
    let output = client.execute("whoami")?;
    println!("Output: {}", output.stdout.trim());

    // Execute another command
    println!("\nExecuting: hostname");
    let output = client.execute("hostname")?;
    println!("Output: {}", output.stdout.trim());

    // Execute a command with more output
    println!("\nExecuting: uname -a");
    let output = client.execute("uname -a")?;
    println!("Output: {}", output.stdout.trim());

    println!("\n✓ All commands executed successfully!");

    Ok(())
}
