|
|
|
namespace Commands
|
|
|
|
|
|
|
|
module ConsoleCommands =
|
|
|
|
|
|
|
|
open System
|
|
|
|
open Console.Waterworks
|
|
|
|
open Console.Waterworks.Attributes
|
|
|
|
open SmoulderingBeachBall.Services
|
|
|
|
open Validation
|
|
|
|
open System.IO
|
|
|
|
|
|
|
|
let showEndOfCommandMessage = "[INFO.] Execution completed."
|
|
|
|
|
|
|
|
[<ListCommand>]
|
|
|
|
[<Parameters "none">]
|
|
|
|
[<Description
|
|
|
|
"Display a text message indicating this program is running properly.">]
|
|
|
|
[<Usage "test">]
|
|
|
|
let test () = "[SUCCESS] Smouldering Beach Ball CLI seems to be 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 "Saves this program's cheat sheet to the desktop.">]
|
|
|
|
[<Usage "cheat">]
|
|
|
|
let cheat () =
|
|
|
|
try
|
|
|
|
printfn "[INFO] Attempting to save cheat sheet to the desktop..."
|
|
|
|
let cheatSheetPath = __SOURCE_DIRECTORY__ + "/cheat-sheet.pdf"
|
|
|
|
let savePath = getDesktopPath + "/smouldering-beach-ball-cheat-sheet.pdf"
|
|
|
|
File.Copy (cheatSheetPath, savePath, true)
|
|
|
|
showEndOfCommandMessage
|
|
|
|
with
|
|
|
|
| :? FileNotFoundException as ex -> ex.Message
|
|
|
|
| _ as ex -> ex.Message
|
|
|
|
|
|
|
|
[<ListCommand>]
|
|
|
|
[<Parameters "none">]
|
|
|
|
[<Description "Exits out of the program.">]
|
|
|
|
[<Usage "exit">]
|
|
|
|
let exit () = Environment.Exit (Environment.ExitCode)
|
|
|
|
|
|
|
|
[<ListCommand>]
|
|
|
|
[<Parameters "(image-width: int) (image-height: int)" >]
|
|
|
|
[<Description
|
|
|
|
("Saves an image to the desktop, using the default setting.\n" +
|
|
|
|
"The user must specify the width and the height of the image.")>]
|
|
|
|
[<Usage "draw-default 500 500">]
|
|
|
|
let ``draw-default`` imgWidth imgHeight =
|
|
|
|
try
|
|
|
|
buildDefaultSpec imgWidth imgHeight
|
|
|
|
|> makeImage
|
|
|
|
|> Async.RunSynchronously
|
|
|
|
showEndOfCommandMessage
|
|
|
|
with
|
|
|
|
| :? ArgumentException as ex -> ex.Message
|
|
|
|
| _ as ex -> ex.Message
|
|
|
|
|
|
|
|
[<ListCommand>]
|
|
|
|
[<Parameters
|
|
|
|
("(image-width: int) (image-height: int) (main-colour: string) " +
|
|
|
|
"(overlay-colour: string) (overlay-type: string) (file-path: string)")>]
|
|
|
|
[<Description
|
|
|
|
("\nCreates an image using the values specified by the user.\n" +
|
|
|
|
"To see a list of available colours use the 'list-colours' command.\n" +
|
|
|
|
"For the overlay-type you can enter either 'none', 'border' or 'full.'\n" +
|
|
|
|
"For the file path, you can enter 'desktop' to save to the desktop.\n" +
|
|
|
|
"Otherwise, you must specify the whole path.")>]
|
|
|
|
[<Usage
|
|
|
|
("\ndraw-image 770 400 white black full desktop\n" +
|
|
|
|
"draw-image 600 400 purple grey border C:/work/project-folder/images\n" +
|
|
|
|
"draw-image 800 440 black - none D:/your-project/assets")>]
|
|
|
|
let ``draw-image`` imgWidth imgHeight mainColour oColour oType path =
|
|
|
|
try
|
|
|
|
buildSpec imgWidth imgHeight mainColour oColour oType path
|
|
|
|
|> makeImage
|
|
|
|
|> Async.RunSynchronously
|
|
|
|
showEndOfCommandMessage
|
|
|
|
with
|
|
|
|
| :? ArgumentException as ex -> ex.Message
|
|
|
|
| _ as ex -> ex.Message
|
|
|
|
|
|
|
|
[<ListCommand>]
|
|
|
|
[<Parameters "None">]
|
|
|
|
[<Description "Lists out the colours this program uses to draw its images.">]
|
|
|
|
[<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/Smouldering-Beach-Ball/wiki *)
|
|
|
|
|
|
|
|
let dd imgWidth imgHeight =
|
|
|
|
``draw-default`` imgWidth imgHeight
|
|
|
|
|
|
|
|
let di imgWidth imgHeight mainColour oColour oType path =
|
|
|
|
``draw-image`` imgWidth imgHeight mainColour oColour oType path
|
|
|
|
|
|
|
|
let lc () = ``list-colours`` ()
|