use ../config/accessor.nu *
use interface.nu [_ansi _print end_run]
use init.nu [get-provisioning-name]

export def option_undefined [
  root: string
  src: string
  info?: string
] {
  _print $"🛑 invalid_option ($src) ($info)"
  _print $"\nUse (_ansi blue_bold)((get-provisioning-name)) ($root) ($src) help(_ansi reset) for help on commands and options"
}

export def invalid_task [
  src: string
  task: string
  --end
] {
  let show_src = {|color|
    if $src == "" { "" } else { $" (_ansi $color)($src)(_ansi reset)"}
  }
  if $task != "" {
    _print $"🛑 invalid (_ansi blue)((get-provisioning-name))(_ansi reset)(do $show_src "yellow") task or option: (_ansi red)($task)(_ansi reset)"
  } else {
    _print $"(_ansi blue)((get-provisioning-name))(_ansi reset)(do $show_src "yellow") no task or option found !"
  }
  _print $"Use (_ansi blue_bold)((get-provisioning-name))(_ansi reset)(do $show_src "blue_bold") (_ansi blue_bold)help(_ansi reset) for help on commands and options"
  if $end and not ($env.PROVISIONING_DEBUG? | default false) { end_run "" }
}
