# demo-java


set-strictmode -version 2.0

function defineFlowTask([Flow]$flow,[Task]$task) {
#--- define
  $def = new-module -asCustomObject -scriptBlock {
    function getTaskDesc([Task]$task) {
      return "Invokes $($task.name)-run.ps1 in $($task.execLocn)"
    }

    # ---------- define task parameters
    function params([Object]$task,[hashtable]$htOpts) {
      $parms = @{};
      $parms.brief    = "$($task.statlocn)"
      $parms.str      = "create Brief"
      $parms.gen      = "5"
      $parms.genstr   = "output line from parm definition line="
      $parms.bool1    = $null
      $parms['swkey=']  = 'key-value';
      return  $parms
    }

    # ---------- the actual script
    function runScript([Task]$task, [hashtable]$parms, [hashtable]$status) {
      $tfs = $task.tfs;
      $locn = $task.execLocn
      $scr = "$($task.execLocn)/$($task.name)-run.ps1";
      hlogBoth("Invoking $scr")

      [hashtable]$parms = @{}
      forEach($vbl in $task.taskCfg.keys) {
        if ($vbl -match "^parm-") {
          $key = $vbl.substring(5);
          $parms[$key] = $task.taskCfg[$vbl];
        }
        #hlogBoth("$vbl value $($cfg[$vbl])");
      }


      $status.aInvoke = "Invoked $scr"
      $retStr = (. $scr $task $parms $status)
      return "$scr `r`n==================================run-reneric-script===================`r`n $retStr"

    }
    Export-ModuleMember -Variable * -Function *
  }
  $task.defLogWid = 1800
  hlog("define-task $flow $task")
  return $def;
}



X
PSEC - Powershell Enhanced Capability
1.2.1
  src: run-generic-script-run-generic-script-run-generic-script-lib.psm1

Copyright © 2018-2021, 2022, Rexcel System Inc.