|
|
|
@ -1,15 +1,16 @@
|
|
|
|
|
using Console.Waterworks; |
|
|
|
|
using Console.Waterworks.Attributes; |
|
|
|
|
using Microsoft.FSharp.Control; |
|
|
|
|
using Microsoft.FSharp.Core; |
|
|
|
|
using System; |
|
|
|
|
using static WetPancake.Pancake; |
|
|
|
|
using static System.Environment; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
using Microsoft.FSharp.Control; |
|
|
|
|
using Microsoft.FSharp.Core; |
|
|
|
|
using System.Threading; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Windows.Forms; |
|
|
|
|
using static System.Environment; |
|
|
|
|
using static System.Console; |
|
|
|
|
using static WetPancake.Pancake; |
|
|
|
|
|
|
|
|
|
namespace WetPancakeCLI |
|
|
|
|
{ |
|
|
|
@ -17,8 +18,10 @@ namespace WetPancakeCLI
|
|
|
|
|
{ |
|
|
|
|
// Pass these in when running an FSharpAsync task. |
|
|
|
|
// Examples are within the command-methods. |
|
|
|
|
static FSharpOption<TaskCreationOptions> _taskCreationOptions = FSharpOption<TaskCreationOptions>.None; |
|
|
|
|
static FSharpOption<CancellationToken> _cancellationToken = FSharpOption<CancellationToken>.None; |
|
|
|
|
static readonly FSharpOption<TaskCreationOptions> _taskCreationOptions = FSharpOption<TaskCreationOptions>.None; |
|
|
|
|
static readonly FSharpOption<CancellationToken> _cancellationToken = FSharpOption<CancellationToken>.None; |
|
|
|
|
|
|
|
|
|
static void CopyToClipBoard(string text) => Clipboard.SetText(text); |
|
|
|
|
|
|
|
|
|
#region Console Utilities |
|
|
|
|
[ListCommand] |
|
|
|
@ -184,15 +187,19 @@ namespace WetPancakeCLI
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[ListCommand] |
|
|
|
|
[Description("Generates random text, the number of sentences generated is randomly determined.")] |
|
|
|
|
[Parameters("None")] |
|
|
|
|
[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")] |
|
|
|
|
[Usage("> GenerateRandomText")] |
|
|
|
|
public static string GenerateRandomText() |
|
|
|
|
public static string GenerateRandomText(bool copyToClipboard = false) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
return FSharpAsync.StartAsTask |
|
|
|
|
var result = FSharpAsync.StartAsTask |
|
|
|
|
(RequestRandomTextAsync(), _taskCreationOptions, _cancellationToken).Result; |
|
|
|
|
if (copyToClipboard == true) CopyToClipBoard(result); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
|