diff --git a/SmoulderingBeachBall/InternalServices.fs b/SmoulderingBeachBall/InternalServices.fs index ac0df8f..1f80d0e 100644 --- a/SmoulderingBeachBall/InternalServices.fs +++ b/SmoulderingBeachBall/InternalServices.fs @@ -59,7 +59,7 @@ graphics.FillRectangle (spec.colour, rectangle) match spec.overlay.IsSome with | true -> addOverlayToImage graphics spec - | false -> printfn "[INFO.] No overlay specified. Creating image without one." + | false -> printfn "[INFO.] No overlay specified. Creating image withoutone." bitmap.Save (spec.filePath) - bitmap.Dispose() - graphics.Dispose() \ No newline at end of file + graphics.Dispose() + bitmap.Dispose() \ No newline at end of file diff --git a/SmoulderingBeachBallCLI/ConsoleCommands.fs b/SmoulderingBeachBallCLI/ConsoleCommands.fs index 5d89e80..16322be 100644 --- a/SmoulderingBeachBallCLI/ConsoleCommands.fs +++ b/SmoulderingBeachBallCLI/ConsoleCommands.fs @@ -2,28 +2,30 @@ module ConsoleCommands = + open System open Console.Waterworks - open SmoulderingBeachBall + open SmoulderingBeachBall.Domain open SmoulderingBeachBall.Services - open System + open Validation + open System.Drawing - let test () = "This program is working." + let showEndOfCommandMessage = "[INFO.] Execution completed." - let exit () = Environment.Exit (Environment.ExitCode) + let test () = "Smouldering Beach Ball CLI seems to be working." - let ``draw-image`` () = - // makeImage - //"Image completed." - "Command not implemented." + let exit () = Environment.Exit (Environment.ExitCode) + let ``draw-image`` imgWidth imgHeight mainColour path = + buildBasicSpec imgWidth imgHeight mainColour path + |> makeImage + |> Async.RunSynchronously + showEndOfCommandMessage let ``draw-borderedImage`` () = - //"Image completed." - "Command not implemented." + showEndOfCommandMessage let ``draw-overlayedImage`` () = - //"Image completed." - "Command not implemented." + showEndOfCommandMessage diff --git a/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj b/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj index 6aaefd4..b2b8541 100644 --- a/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj +++ b/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj @@ -46,6 +46,7 @@ + @@ -61,6 +62,10 @@ + + + ..\packages\System.Drawing.Common.4.5.0\lib\net461\System.Drawing.Common.dll + True diff --git a/SmoulderingBeachBallCLI/Validation.fs b/SmoulderingBeachBallCLI/Validation.fs new file mode 100644 index 0000000..e2912e8 --- /dev/null +++ b/SmoulderingBeachBallCLI/Validation.fs @@ -0,0 +1,39 @@ +module Validation + + open System.Drawing + open SmoulderingBeachBall.Domain.DomainTypes + + let colourList = + [ "blue", Brushes.AliceBlue; + "brown", Brushes.Brown; + "black", Brushes.Black; + "gray", Brushes.Gray; + "green", Brushes.Green; + "purple", Brushes.Purple; + "red", Brushes.Red; + "white", Brushes.White; + "yellow", Brushes.Yellow;] + |> Map.ofList + + let isColourValid (colour: string) = + colourList + |> Map.containsKey (colour.ToLower()) + + let parseColour colour = + match (isColourValid colour) with + | true -> + colourList + |> Map.find (colour.ToLower()) + | false -> + invalidArg "Colour" "The colour specifed cannot is invalid." + // "Please use the ListAvailableColours command for a list"? + + let buildBasicSpec iWidth iHeight mainColour path = + let brush = (parseColour mainColour) + let spec = + { width = iWidth; + height = iHeight; + colour = brush + filePath = path + overlay = None } + spec \ No newline at end of file diff --git a/SmoulderingBeachBallCLI/packages.config b/SmoulderingBeachBallCLI/packages.config index daebccc..45c38e7 100644 --- a/SmoulderingBeachBallCLI/packages.config +++ b/SmoulderingBeachBallCLI/packages.config @@ -2,5 +2,6 @@ + \ No newline at end of file