Browse Source

Add Copy ToClipboard functionality to GenerateCleanText command-methods.

master
Craig Oates 6 years ago
parent
commit
f095bc004e
  1. 20
      WetPancakeCLI/ConsoleCommands.cs

20
WetPancakeCLI/ConsoleCommands.cs

@ -129,10 +129,13 @@ namespace WetPancakeCLI
"The result goes through an extra \"cleaning\" process to remove any artefact sentences.\n" + "The result goes through an extra \"cleaning\" process to remove any artefact sentences.\n" +
"Use this if you cannot tolerate the odd extra sentence.\n" + "Use this if you cannot tolerate the odd extra sentence.\n" +
"With that said, it does mean it is slower than its GenerateText counterpart.\n" + "With that said, it does mean it is slower than its GenerateText counterpart.\n" +
"Gibberish-level must be between 2 and 20.")] "Gibberish-level must be between 2 and 20.\n" +
[Parameters("gibberish-level: int, sentences: int")] "Sentences must be greater than 0.\n" +
[Usage("> GenerateCleanText 5 10")] "Pass in \"true\" to copy the result straight to the clipboard.\n" +
public static string GenerateCleanText(int gibberishLevel, int sentences) "Pass in \"false\" or leave blank to not copy the result.")]
[Parameters("gibberish-level: int, sentences: int, copy-to-clip-board: bool")]
[Usage("> GenerateCleanText 5 10 true | > GenerateCleanText 5 4")]
public static string GenerateCleanText(int gibberishLevel, int sentences, bool copyToClipboard = false)
{ {
try try
{ {
@ -142,8 +145,11 @@ namespace WetPancakeCLI
if (sentences < 1) if (sentences < 1)
throw new ArgumentException throw new ArgumentException
("Invalid argument. Must be greater than 0.", "sentences"); ("Invalid argument. Must be greater than 0.", "sentences");
return FSharpAsync.StartAsTask var result = FSharpAsync.StartAsTask(
(RequestCleanTextAsync(gibberishLevel, sentences), _taskCreationOptions, _cancellationToken).Result; RequestCleanTextAsync(gibberishLevel, sentences), _taskCreationOptions, _cancellationToken)
.Result;
if (copyToClipboard == true) CopyToClipBoard(result);
return result;
} }
catch (Exception e) catch (Exception e)
{ {
@ -190,7 +196,7 @@ namespace WetPancakeCLI
[Description( [Description(
"Generates random text, the number of sentences generated is randomly determined\n." + "Generates random text, the number of sentences generated is randomly determined\n." +
"Pass in true to copy result straight to clipboard.")] "Pass in true to copy result straight to clipboard.")]
[Parameters("copy-to-clipbaord: bool")] [Parameters("copy-to-clipboard: bool")]
[Usage("> GenerateRandomText")] [Usage("> GenerateRandomText")]
public static string GenerateRandomText(bool copyToClipboard = false) public static string GenerateRandomText(bool copyToClipboard = false)
{ {

Loading…
Cancel
Save