delete command-methods overview page.

master
Craig Oates 4 years ago
parent
commit
9f5991d195
  1. 64
      Command-Methods-Overview.md

64
Command-Methods-Overview.md

@ -1,64 +0,0 @@
Without going into too much detail, a "command-method" is a function within the `ConsoleCommands` module. The name "command-method" is inaccurate here but I have kept it to remain consistent with Console.Waterworks (C.W). If you would like to know more about command-methods, I recommend you read the following wiki entry:
- [Console.Waterworks Wiki -- Writing Command-Methods](https://git.abbether.net/craig.oates/Console.Waterworks/wikis/Writing-Command-Methods)
For command-methods to work properly, there are several things they need. Which are:
1. There us a module called `ConsoleCommands` in the project.
2. The module must live in a name-space. (The module is this project resides in `Commands`.)
3. `ConsoleCommands` must reference the `Console.Waterworks` namespace (I.E. `open Console.Waterworks`).
4. If using C.W's "help" attributes, you must reference the `Console.Waterworks.Attributes` name-space.
5. Command-methods must be a function (I.E. include unit/`()` in function definitions).
Please note, this list is not complete. With that said, the extra stuff is more to do with using C.W. in a C# project. If you would like to know more about using C.W. with F# and how it differs from using it with C#, checkout the following link:
- [Brittle Fish Repository](https://git.abbether.net/craig.oates/Brittle-Fish)
Having got the above out of the way, here is a couple of command-method examples to help you get a feel for how they look.
```f#
[<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 // This is what is returned.
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 // This is what is returned.
```
To help explain what the above code, please consider the image below.
![command-method binding example](command-method-binding-example.png)
It is not essential to include the help attributes but they do provide help for the end-user and future developers. For more information about the help attributes, please use the following links:
- [Console.Waterworks Wiki -- Using the "Help Attributes"](https://git.abbether.net/craig.oates/Console.Waterworks/wikis/Using-the-%22Help-Attributes%22)
- [Brittle Fish Wiki](https://git.abbether.net/craig.oates/Brittle-Fish/wikis/home)
The name of the command-method is what the end-user must enter into the console. If the command-method requires input arguments, the end-user must provide them, as well. For example, please consider the following image:
![command-method matching run-time command](command-method-matching-run-time-command.png)
If all has gone well, you should be able to work your way through "ConsoleCommands.fs" and understand it. With that said, you will come across functions which appear to have no explanation for why the exist. If you dig around a little bit, you will notice these functions are either situated in "Validation.fs" or the .Net Standard library (I.E. "SmoulderingBeachBall"). Use the following links for more information:
- [ConsoleCommands.fs](https://git.abbether.net/craig.oates/Smouldering-Beach-Ball/blob/master/SmoulderingBeachBallCLI/ConsoleCommands.fs)
- [Validation.fs](https://git.abbether.net/craig.oates/Smouldering-Beach-Ball/blob/master/SmoulderingBeachBallCLI/Validation.fs)
- [Services.fs (SmoulderingBeachBall)](https://git.abbether.net/craig.oates/Smouldering-Beach-Ball/blob/master/SmoulderingBeachBall/Services.fs)
- [Console(Commands) A.P.I. (As C.L.I. section)](https://git.abbether.net/craig.oates/Smouldering-Beach-Ball/wikis/Console-API)
Loading…
Cancel
Save