Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param (
  2.     $p1,
  3.     [String]$Input_1
  4. )
  5.  
  6. function Info([String]$s) {
  7.     if ([String]::IsNullOrWhiteSpace($s)) {
  8.         return 1
  9.     }
  10.     if ($s -eq '?' -or $s -eq 'help') {
  11.         return 2
  12.     }
  13.     if ($s -eq '--help' -or $s -eq '--h') {
  14.         return 3
  15.     }
  16.     if ($s -eq "-h") {
  17.         return 4
  18.     }
  19. }
  20.  
  21. function test {
  22.     $args
  23.     foreach($arg in $args) {
  24.         switch($arg) {
  25.             '-h' { 'I got: -h' }
  26.             '--help' { 'I got: --help' }
  27.             default { "I got something: $arg" }
  28.         }
  29.     }
  30. }
  31.  
  32. test($p1)
  33.  
  34. # switch(Info($Input_1)) {
  35. #   { $_ -eq 1 } {Write-Output "[ps-test] Usage: ps-test ... Variant 1"; Exit}
  36. #   { $_ -eq 2 } {Write-Output "[ps-test] Usage: ps-test ... Variant 2"; Exit}
  37. #   { $_ -eq 3 } {Write-Output "[ps-test] Usage: ps-test ... Variant 3"; Exit}
  38. #   { $_ -eq 4 } {Write-Output "[ps-test] Usage: ps-test ... Variant 4"; Exit}
  39. # }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement