# demo-options


#using module h:\psec\flows\run-gael\setup-run-gael.psm1;
#using module h:\psec\lib\lib-setup-run-gael.psm1;

set-strictmode -version 2.0


function defineFlowTask([Flow]$flow,[Task]$task) {
#--- define
  $def = new-module -asCustomObject -scriptBlock {
    #[string]$main       = 'org.srp.psec.TestArgsPsec'

    # shows how to present contextual variables
    function getTaskDesc([Task]$task) {
      $tfs = $task.tfs;
      [string]$desc        = @"
This illustrates the conditional showing of a setp based on context. In this example we add a quarterly step.
Current Values: cycleNo=$($tfs.globMap.demoGlobs.cycleNo) month=$($tfs.globMap.demoGlobs.month)`r`n
"@
      return $desc;
    }

    function fetchJavaMain([Object]$task,[hashtable]$parms) {
      return 'org.srp.psec.TestArgsPsec'
    }

    function showWhen([Task]$task){
      $tfs = $task.tfs;
      if ($tfs.globMap.demoGlobs.month -match ('^((mar)|(jun)|(sep)|(dec)|)$')) {return $true;}
      return $false;
    }

    <#
    Fetch classpath setup during Workflow setup.
    #>
    function fetchJavaClassStr([Object]$task,[hashtable]$parms) {
      $tfs = $task.tfs;
      return $($tfs.globMap.demoGlobs.javaLib);
    }

    # ---------- define task parameters
    <#
    The $htOpts parms has the processed options.  It can be modified or used to do
    other changes to the setup.
    #>
      function params {
        param([Object]$task,[hashtable]$htOpts)
        #$tfs = $task.tfs;
        $date = Get-Date
        [string]$dateStr = $date.ToString("yyyyMMdd")

        $htOpts.datestr = $dateStr;
        $htOpts.brief   = "$($task.statlocn)"
        return  $htOpts
      }

      # ---------- define task options
      function options([Task]$task) {
        $opts = @();

        $opts += @{type='input';  parm='gen';     label='Gen';     place='number of lines to generate'; regex='^[0-9]+$'}
        $opts += @{type='input';  parm='genstr';  label='GenStr';  place='string to generate'}
        $opts += @{type='check';  parm='bool1';   label='bool1';   place='turns on bool1 option when checked'}
        $opts += @{type='radio';  parm='trap';    label='trap';    valset='*/*no trap,fail/gen FAIL,trap/gen TRAP'}
        $opts += @{type='combo';  parm='combo';   label='combo';   valset='*/*--none--,green,red/show red,blue/set blue'}
        return  ,$opts
      }

      Export-ModuleMember -Variable * -Function *

  }
  hlog("defineFlowTask $flow $task")

  return $def;
}



X
PSEC - Powershell Enhanced Capability
1.2.1
  src: psec-demo-demo-cond-task-demo-cond-task-def.psm1

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