use std::{
    fmt,
    fmt::{Display, Formatter},
};

use quote::ToTokens;

#[derive(Debug)]
struct DisplayStringSlice<'a>(&'a [&'static str]);

impl Display for DisplayStringSlice<'_> {
    #[inline]
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        for &s in self.0 {
            f.write_str("\n    ")?;
            f.write_str(s)?;
        }

        Ok(())
    }
}

#[inline]
pub(crate) fn sub_attributes_for_item(tokens: impl ToTokens) -> syn::Error {
    syn::Error::new_spanned(
        tokens,
        format!(
            "available sub-attributes for the `orderByOptions` attribute:{}",
            DisplayStringSlice(&["name", "join"])
        ),
    )
}
