Death Socket consists of three projects. They are a .Net Standard 2.0 library, a console program and a Test Centre. The purpose of this repository is to provide a way for people to add grids to images. https://www.craigoates.net/Software/project/13
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.8 KiB

namespace Commands
module ConsoleCommands =
open System
open DeathSocket.GridPainter
open DeathSocketCLI.Validation
open System.IO
open Console.Waterworks
open Console.Waterworks.Attributes
let showEndOfCommandMessage = "[INFO.] Task completed."
[<ListCommand>]
[<Parameters "none">]
[<Description
"Display a text message indicating this program is running properly.">]
[<Usage "test">]
let test () = "[SUCCESS] Death Socket is working."
[<ListCommand>]
[<Parameters "none">]
[<Description "Displays a list of available commands provided by this program.">]
[<Usage "help">]
let help () = CW_Liaison().RequestHelpDocumentation("Commands")
[<ListCommand>]
[<Parameters "none">]
[<Description "Exits out of the program.">]
[<Usage "exit">]
let exit () = Environment.Exit (Environment.ExitCode)
[<ListCommand>]
[<Parameters "(image-path: string) (new-path: string)">]
[<Description
"Takes the image at 'image-path' applies a 10x10 grid (in white) to it and saves the result at 'new-path'.">]
[<Usage "add-default C:/base-image.png C:/final-image.png">]
let ``add-default`` imgPath newPath =
try
printfn "[INFO.] Adding default grid to image..."
buildDefaultSpec imgPath newPath
|> applyBrushSpecGridAsync
|> Async.Start
showEndOfCommandMessage
with
| :? FileNotFoundException as ex -> "[ERROR] No file was found at " + ex.FileName
| :? ArgumentException as ex -> "[ERROR] Invalid argument: " + ex.Message
| _ as ex -> ex.Message
[<ListCommand>]
[<Parameters
("(image-path: string) (no-of-rows: int) (no-of-columns: int) " +
"(pen-width: float32) (colour: string) (new-path: string)")>]
[<Description "Adds a grid to an image, using the specified parameters, and saves it.">]
[<Usage
"add-grid C:/orignal-image.png 10 5 2 red C:/new-image.png">]
let ``add-grid`` imgPath numRows numColumns pWidth colour newPath =
try
printfn "[INFO.] Adding grid to image..."
buildSpec imgPath numRows numColumns pWidth colour newPath
|> applyBrushSpecGridAsync
|> Async.Start
showEndOfCommandMessage
with
| :? FileNotFoundException as ex -> "[ERROR] No file was found at " + ex.FileName
| :? ArgumentException as ex -> "[ERROR] Invalid argument: " + ex.Message
| _ as ex -> ex.Message
[<ListCommand>]
[<Parameters "none">]
[<Description
"Lists out the colours this program uses to draw its grids.">]
[<Usage "list-colours">]
let ``list-colours`` () =
printfn "[INFO.] Listing available colours..."
for item in colourList do
printfn "%s" item.Key
showEndOfCommandMessage
(* ALIASES
=======================================================================
These command-methods will not show up in the help section. Before
adding extra aliases, make sure the main version is as clear and
helpful to someone new to the program as possible. Aliases should be
treated as commands for experienced users and documented on the wiki,
hosted alongside the repository on GitHub.
URL: https://github.com/CraigOates/Death-Socket/wiki *)
let ad imgPath newPath = ``add-default`` imgPath newPath
let ag imgPath numRows numColumns pWidth colour newPath =
``add-grid`` imgPath numRows numColumns pWidth colour newPath
let lc () =``list-colours`` ()