diff --git a/SmoulderingBeachBallCLI/ConsoleCommands.fs b/SmoulderingBeachBallCLI/ConsoleCommands.fs index f14b253..1499555 100644 --- a/SmoulderingBeachBallCLI/ConsoleCommands.fs +++ b/SmoulderingBeachBallCLI/ConsoleCommands.fs @@ -12,6 +12,13 @@ let exit () = Environment.Exit (Environment.ExitCode) + (* possibe function -- save to desktop and almost set to "default"? + might be to goto for most command calls... + let `draw-basic` imgWidth imgHeight = + buildSimpleSpec + |> makeImage + *) + let ``draw-image`` imgWidth imgHeight mainColour path = try buildBasicSpec imgWidth imgHeight mainColour path @@ -22,13 +29,22 @@ | :? ArgumentException as ex -> ex.Message | _ as ex -> ex.Message - let ``draw-borderedImage`` () = - - showEndOfCommandMessage + let ``draw-borderedImage`` imgWidth imgHeight mainColour oColour oType path = + try + buildOverlaySpec imgWidth imgHeight mainColour oColour oType path + |> makeImage + |> Async.RunSynchronously + showEndOfCommandMessage + with + | :? ArgumentException as ex -> ex.Message + | _ as ex -> ex.Message let ``draw-overlayedImage`` () = - - showEndOfCommandMessage + try + showEndOfCommandMessage + with + | :? ArgumentException as ex -> ex.Message + | _ as ex -> ex.Message let ``list-colours`` () = printfn "[INFO.] Listing available colours..." diff --git a/SmoulderingBeachBallCLI/Validation.fs b/SmoulderingBeachBallCLI/Validation.fs index acf629a..c897477 100644 --- a/SmoulderingBeachBallCLI/Validation.fs +++ b/SmoulderingBeachBallCLI/Validation.fs @@ -38,13 +38,34 @@ Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) | _ -> path - let buildBasicSpec iWidth iHeight mainColour path = - let brush = (parseColour mainColour) - let parsedPath = parsePath path + let buildBasicSpec iWidth iHeight mainColour path = let spec = { width = iWidth; height = iHeight; - colour = brush - filePath = parsedPath + colour = parseColour mainColour + filePath = parsePath path overlay = None } + spec + + let parseOverlay (oType: string) = + match oType.ToLower() with + | "border" -> Border + | "b" -> Border + | "full" -> Full + | "f" -> Full + | _ -> invalidArg "Overlay Type" "The overlay type must be either 'border' or 'full'." + + // Need to think about building the two spec's seperately and bring them together in one place. + // I'm repeating myself a little too much here. + // Also, need to adjust pen width to match the image size (in library proj.). + let buildOverlaySpec iWidth iHeight mainColour oColour oType path = + let oSpec = + { colour = parseColour oColour; + overlayType = parseOverlay oType } + let spec = + {width = iWidth; + height = iHeight; + colour = parseColour mainColour; + filePath = parsePath path; + overlay = Some oSpec } spec \ No newline at end of file