# WARNING - Generated by {fusen} from dev/flat_kwb_simulate_inflow.Rmd: do not edit by hand # nolint: line_length_linter.

#' Enumerate Elements
#'
#' This function does the same thing as kwb.utils::enumeration(),
#' but it is bundled with *ambre* to avoid a hard dependency on the
#' unmaintained package.
#'
#' @param x vector of elements to be enumerated
#' @param type type of element to appear in the message. Default: "element"
#' @param sorted logical. Whether or not to print the available elements in
#'   lexical order. Default: \code{FALSE}
#' @param suffix suffix to be appended to \code{type}. Can be used to
#'   distinguish between singular and plural form. Default: \code{""}
#' @return character string containing the enumeration
#' @references
#'   Sonnenberg H (2024). kwb.utils: General Utility Functions Developed at KWB. R package version 0.15.0
#'   URL: \url{https://github.com/kwb-r/kwb.utils}
#'   (MIT Licence)
#' @export
#' @examples
#'
#' # Example usage of enumeration
#' cat(enumeration(c("a", "b", "c"), type = "element"))
#' cat(enumeration(c("x", "y"), type = "element", suffix = "s"))
enumeration <- function(x, type = "element", sorted = FALSE, suffix = "")
{
  sprintf(
    "%s%s%s%s:\n- %s\n", 
    type,
    ifelse(length(x) > 1L, "s", ""), # plural "s"
    ifelse(length(x) > 1L && sorted, " (sorted)", ""), 
    suffix,
    stringList(if (sorted) sort(x) else x, collapse = "\n- ")
  )
}
