Created
March 6, 2019 18:25
-
-
Save tsukanov-as/b92df0c30e5f33f812f1b970fd5cbaf1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Collections.Generic | |
#region Runtime | |
Add-Type -AssemblyName System.speech | |
$Ирина = New-Object System.Speech.Synthesis.SpeechSynthesizer | |
cls | |
$lib = @{ | |
"Ничего" = {} | |
"Я пишу числа [] в файл []" = { | |
$args[0] | Out-File $args[1] | |
} | |
"В файле [] [] строки" = { | |
$data = Get-Content $args[0] | |
if ($data.count -ne $args[1]) { | |
$text = "Чет пошло не так" | |
$Ирина.Speak($text) | |
throw $text | |
} | |
} | |
"Скажи [] голосом []" = { | |
$args[0], $args[1] | |
$null = $args[1].SpeakAsync($args[0]) | |
} | |
} | |
function Run ($words) { | |
$step = [list[string]]::new() | |
$pars = [list[object]]::new() | |
foreach ($word in $words) { | |
if ($word -is [string]) { | |
if ($word.StartsWith("[")) { | |
if (-not $word.EndsWith("]")) { | |
throw "параметр `"$word`" должен оканчиваться на `"]`"" | |
} | |
$pars.Add($word.Substring(1, $word.Length - 2)) | |
$step.Add("[]") | |
} | |
else { | |
$step.Add($word) | |
} | |
} | |
else { # object | |
$pars.Add($word) | |
$step.Add("[]") | |
} | |
} | |
$name = $step -join " " | |
$code = $lib[$name] | |
if ($null -eq $code) { | |
throw "Не найдена реализация шага `"$name`"" | |
} | |
Invoke-Command $code -ArgumentList $pars | |
} | |
function Дано { Run $args } | |
function Когда { Run $args } | |
function Тогда { Run $args } | |
function И { Run $args } | |
function * { Run $args } | |
#endregion | |
<# Горемыкин #> | |
Дано Ничего | |
* Скажи ["Начинаю телодвижения"] голосом $Ирина | |
Когда Я пишу числа 1, 2, 3 в файл [вася.txt] | |
Тогда В файле [вася.txt] 3 строки | |
* Скажи [Закончила] голосом $Ирина |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment