|
|
|
@ -87,10 +87,17 @@ namespace WetPancakeCLI
|
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (gibberishLevel < 2 || gibberishLevel > 20) throw new ArgumentException("Invalid argument. Must be between 2 and 20 (inclusive).", "gibberishLevel"); |
|
|
|
|
if (sentences < 1) throw new ArgumentException("Invalid argument. Must be greater than 0.", "sentences"); |
|
|
|
|
if (Path.GetExtension(filePath) != ".txt") throw new FileLoadException("The file entered is not a plain text (.txt) file.", filePath); |
|
|
|
|
return FSharpAsync.StartAsTask(RequestTextFromFileAsync(gibberishLevel, sentences, filePath), _taskCreationOptions, _cancellationToken).Result; |
|
|
|
|
if (gibberishLevel < 2 || gibberishLevel > 20) |
|
|
|
|
throw new ArgumentException |
|
|
|
|
("Invalid argument. Must be between 2 and 20 (inclusive).", "gibberishLevel"); |
|
|
|
|
if (sentences < 1) |
|
|
|
|
throw new ArgumentException |
|
|
|
|
("Invalid argument. Must be greater than 0.", "sentences"); |
|
|
|
|
if (Path.GetExtension(filePath) != ".txt") |
|
|
|
|
throw new FileLoadException |
|
|
|
|
("The file entered is not a plain text (.txt) file.", filePath); |
|
|
|
|
return FSharpAsync.StartAsTask |
|
|
|
|
(RequestTextFromFileAsync(gibberishLevel, sentences, filePath), _taskCreationOptions, _cancellationToken).Result; |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
@ -122,6 +129,7 @@ namespace WetPancakeCLI
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Add "Help" attribute to GenerateCleanText command-method. |
|
|
|
|
public static string GenerateCleanText(int gibberishLevel, int sentences) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
@ -141,5 +149,29 @@ namespace WetPancakeCLI
|
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//TODO: Add "HElp" attribute to GenerateCleanTextFromFile command-method. |
|
|
|
|
public static string GenerateCleanTextFromFile(int gibberishLevel, int sentences, string filePath) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (gibberishLevel < 2 || gibberishLevel > 20) |
|
|
|
|
throw new ArgumentException |
|
|
|
|
("Invalid argument. Must be between 2 and 20 (inclusive).", "gibberishLevel"); |
|
|
|
|
if (sentences < 1) |
|
|
|
|
throw new ArgumentException |
|
|
|
|
("Invalid argument. Must be greater than 0.", "sentences"); |
|
|
|
|
if (Path.GetExtension(filePath) != ".txt") |
|
|
|
|
throw new FileLoadException |
|
|
|
|
("The file entered is not a plain text (.txt) file.", filePath); |
|
|
|
|
return FSharpAsync.StartAsTask |
|
|
|
|
(RequestCleanTextFromFileAsync(gibberishLevel, sentences, filePath), _taskCreationOptions, _cancellationToken).Result; |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
|
Debug.WriteLine(e.Message); |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|