aftman 0.2.2

Aftman is a command line toolchain manager
use anyhow::ensure;

/// Ensures that the given ident fits the rules that we set for Aftman, with
/// nice error reporting.
pub fn check_ident(ident_type: &str, ident: &str) -> anyhow::Result<()> {
    ensure!(ident.len() > 0, "{} must be non-empty", ident_type);
    ensure!(
        !ident.chars().all(char::is_whitespace),
        "{} must be non-empty",
        ident_type
    );
    ensure!(
        ident.chars().all(|c| c != '/'),
        "{} must not contain a slash",
        ident_type
    );

    Ok(())
}