! Run EXPLAIN/CHECK on all commands in specified option tree
!
! @author Jay Hallam / Neon Ngo
! @version $Id: checkexplain.mm,v 1.1 2011/04/11 22:16:16 ntn Exp $
startmacro S:OPT[""]
  info "Checking commands in [^{opt}] option tree..."

  set L:commandCount    0
  set L:commandWithWarn 0
  set L:totalWarnings   0
  new java.lang.StringBuilder cmdWithMissingArgs
  set tempfile "ram:temp"
  menu/f=tempfile opt=^opt
  foreach item infile tempfile
    info "Checking command: ^{item}"
    calc L:commandCount commandCount 1 +
    explain/check/warn/out=numArgMissing ^item
    if numArgMissing rexists AND numArgMissing gt 0 then
      warn "Found ^{numArgMissing} undocumented arguments for ^{item}! <--"
      calc L:commandWithWarn commandWithWarn 1 +
      calc L:totalWarnings totalWarnings numArgMissing +
      invoke ,, cmdWithMissingArgs.append("^{item} ")
    endif
  endfor
  say ""
  info "Checked ^{commandCount} commands in [^{opt}]. Found ^{totalWarnings} total missing arguments in ^{commandWithWarn} commands."
  if commandWithWarn gt 0 then
    info ^cmdWithMissingArgs
  endif
  erase tempfile
endmacro
