From 7723d54b702a433fbbd039957d7839c0b6b4a899 Mon Sep 17 00:00:00 2001 From: "OPTIMUS-PRIME\\craig" Date: Mon, 3 Sep 2018 16:20:55 +0100 Subject: [PATCH] add draw-default command-method. Add function for building a default image spec in CLI. --- SmoulderingBeachBallCLI/ConsoleCommands.fs | 10 ++++++++++ SmoulderingBeachBallCLI/Validation.fs | 22 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/SmoulderingBeachBallCLI/ConsoleCommands.fs b/SmoulderingBeachBallCLI/ConsoleCommands.fs index 1499555..a8479b8 100644 --- a/SmoulderingBeachBallCLI/ConsoleCommands.fs +++ b/SmoulderingBeachBallCLI/ConsoleCommands.fs @@ -19,6 +19,16 @@ |> makeImage *) + let ``draw-default`` imgWidth imgHeight = + try + buildDefaultSpec imgWidth imgHeight + |> makeImage + |> Async.RunSynchronously + showEndOfCommandMessage + with + | :? ArgumentException as ex -> ex.Message + | _ as ex -> ex.Message + let ``draw-image`` imgWidth imgHeight mainColour path = try buildBasicSpec imgWidth imgHeight mainColour path diff --git a/SmoulderingBeachBallCLI/Validation.fs b/SmoulderingBeachBallCLI/Validation.fs index c897477..ea1d4a9 100644 --- a/SmoulderingBeachBallCLI/Validation.fs +++ b/SmoulderingBeachBallCLI/Validation.fs @@ -30,14 +30,28 @@ (String.Concat("[ERROR] The colour specifed is invalid.\n", "Please use the 'list-colours' command to see what you can use.")) + let getDesktopPath = + Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + let parsePath (path: string) = match path with - | path when ((path.ToLower()).Equals "desktop") -> - Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) - | path when ((path.ToLower()).Equals "d") -> - Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + | path when ((path.ToLower()).Equals "desktop") -> getDesktopPath + | path when ((path.ToLower()).Equals "d") -> getDesktopPath | _ -> path + let buildDefaultSpec iWidth iHeight = + let oSpec = + { colour = Brushes.Black + overlayType = Full } + let spec = + { width = iWidth + height = iHeight + colour = Brushes.AntiqueWhite + filePath = getDesktopPath + overlay = Some oSpec + } + spec + let buildBasicSpec iWidth iHeight mainColour path = let spec = { width = iWidth;