/**
 * Verbosity management.
 */
module util/config/verbose
imports util/config/common
strategies

 /**
  * Sets the verbosity level.
  *
  * E.g. <set-verbosity> 4 sets the verbosity level to 4.
  *
  * @type Int -> _
  */
  set-verbosity = 
    <set-config> ("--verbose", <id>)

 /**
  * Give the current verbosity level. Default is 1.
  *
  * @type _ -> Int
  */
  verbosity = 
    <get-config> "--verbose" <+ !1

 /**
  * Builds command-line parameter for verbosity levels for calling XT tools.
  *
  * E.g. xtc-transform(!"abox2text", pass-verbose ) passes the verbosity level
  * to abox2text.
  *
  * @type _ -> List(String)
  */
  pass-verbose = 
    !["--verbose", <verbosity; int-to-string> ()]

/**
 * Apply the supplied strategy if the verbosity level is set to a value greater 
 * than or equal to the number given in the strategy name.
 *
 * E.g. if-verbose5(debug) calls the debug strategy if verbosity level is > 5.
 *
 * @param strategy to be applied
 */
strategies

  if-verbose(s|t) = 
    if <geq> (<verbosity> (), t) then
      s
    end

  if-verbose1(s) = if-verbose(s|1)
  if-verbose2(s) = if-verbose(s|2)
  if-verbose3(s) = if-verbose(s|3)
  if-verbose4(s) = if-verbose(s|4) 
  if-verbose5(s) = if-verbose(s|5) 
  if-verbose6(s) = if-verbose(s|6) 
  if-verbose7(s) = if-verbose(s|7)

/**
 * Apply the supplied strategy if the verbosity level is set to a value lesser 
 * than or equal to the number given in the strategy name.
 *
 * E.g. if-less-verbose3(debug) calls the debug strategy if verbosity level is < 3.
 *
 * @param strategy to be applied
 */
strategies

 if-less-verbose(s|t) = 
    if <leq> (<verbosity> (), t) then
      s
    end

  if-less-verbose1(s) = if-less-verbose(s|1)
  if-less-verbose2(s) = if-less-verbose(s|2) 
  if-less-verbose3(s) = if-less-verbose(s|3) 
  if-less-verbose4(s) = if-less-verbose(s|4) 
  if-less-verbose5(s) = if-less-verbose(s|5) 
  if-less-verbose6(s) = if-less-verbose(s|6)
  if-less-verbose7(s) = if-less-verbose(s|7)