From f095bc004ef93a582fc0ea2ecd26f256f1a4a1bf Mon Sep 17 00:00:00 2001 From: "OPTIMUS-PRIME\\craig" Date: Mon, 6 Aug 2018 20:02:25 +0100 Subject: [PATCH] Add Copy ToClipboard functionality to GenerateCleanText command-methods. --- WetPancakeCLI/ConsoleCommands.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/WetPancakeCLI/ConsoleCommands.cs b/WetPancakeCLI/ConsoleCommands.cs index 22f271e..72959d6 100644 --- a/WetPancakeCLI/ConsoleCommands.cs +++ b/WetPancakeCLI/ConsoleCommands.cs @@ -129,10 +129,13 @@ namespace WetPancakeCLI "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" + "With that said, it does mean it is slower than its GenerateText counterpart.\n" + - "Gibberish-level must be between 2 and 20.")] - [Parameters("gibberish-level: int, sentences: int")] - [Usage("> GenerateCleanText 5 10")] - public static string GenerateCleanText(int gibberishLevel, int sentences) + "Gibberish-level must be between 2 and 20.\n" + + "Sentences must be greater than 0.\n" + + "Pass in \"true\" to copy the result straight to the clipboard.\n" + + "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 { @@ -142,8 +145,11 @@ namespace WetPancakeCLI if (sentences < 1) throw new ArgumentException ("Invalid argument. Must be greater than 0.", "sentences"); - return FSharpAsync.StartAsTask - (RequestCleanTextAsync(gibberishLevel, sentences), _taskCreationOptions, _cancellationToken).Result; + var result = FSharpAsync.StartAsTask( + RequestCleanTextAsync(gibberishLevel, sentences), _taskCreationOptions, _cancellationToken) + .Result; + if (copyToClipboard == true) CopyToClipBoard(result); + return result; } catch (Exception e) { @@ -190,7 +196,7 @@ namespace WetPancakeCLI [Description( "Generates random text, the number of sentences generated is randomly determined\n." + "Pass in true to copy result straight to clipboard.")] - [Parameters("copy-to-clipbaord: bool")] + [Parameters("copy-to-clipboard: bool")] [Usage("> GenerateRandomText")] public static string GenerateRandomText(bool copyToClipboard = false) {