Browse Source

Added more comments explaing the F# naming gotchas.

master
Craig Oates 6 years ago
parent
commit
03b36b159f
  1. 16
      BrittleFish/ConsoleCommands.fs
  2. 36
      BrittleFishCore/ConsoleCommands.fs

16
BrittleFish/ConsoleCommands.fs

@ -44,6 +44,22 @@
[<Usage "> libtest3 \"Craig Oates\"">]
let libtest3 name = String.Format("Result: {0}", LibraryTest3 name)
(*
WARNING: Here are some gotchas.
===============================
(I will explain using "test 1" as the example but it applies to all of the below.)
This command-method looks like it works but it is a false-positive.
The reason why it "works" in this instance is because there is a command-method called "Test" up above (line 13).
Console.Waterworks interprets the input as "Test" is the command-method and "1" is a parameter.
The same goes for the others with a space in their name.
Because Test does not take any parameteres, Console.Waterworks ignores the extra input from the user.
Console.Waterworks only worries about the parameters when the command-method specifies it requires them.
GENERAL RULE:
=============
Avoid using F# features for creating variables, functions Etc. with spaces in them.
*)
[<ListCommand>]
[<Description "Displays a message in the console, signfying the command-method is working.">]
[<Parameters "none">]

36
BrittleFishCore/ConsoleCommands.fs

@ -5,13 +5,12 @@
open Console.Waterworks.Core
open Console.Waterworks.Core.Attributes
open FunkyFishCore // This is where the "LibraryTest" functions are -- in BFLibCore
(*
[<ListCommand>]
[<Description "Display a message to the console signifying the program is running as intended.">]
[<Parameters "none">]
[<Usage "> test">]
let test() = "The console is working"
*)
[<ListCommand>]
[<Description "Closes the program.">]
@ -45,35 +44,50 @@
[<Usage "> libtest3 \"Craig Oates\"">]
let libtest3 name = String.Format("Result: {0}", LibraryTest3 name)
(*
WARNING: Here are some gotchas.
===============================
(I will explain using "test 1" as the example but it applies to all of the below.)
This command-method looks like it works but it is a false-positive.
The reason why it "works" in this instance is because there is a command-method called "Test" up above (line 13).
Console.Waterworks interprets the input as "Test" is the command-method and "1" is a parameter.
The same goes for the others with a space in their name.
Because Test does not take any parameteres, Console.Waterworks ignores the extra input from the user.
Console.Waterworks only worries about the parameters when the command-method specifies it requires them.
GENERAL RULE:
=============
Avoid using F# features for creating variables, functions Etc. with spaces in them.
*)
[<ListCommand>]
[<Description "Displays a message in the console, signfying the command-method is working.">]
[<Parameters "none">]
[<Usage "> test 1">]
let ``test 1``() = "Result: Test 1 working"
(* This does not work.*)
[<ListCommand>]
[<Description "Displays a message in the console, signfying the command-method is working. The command uses F#'s double back-tick notation -- hence the command name and usage example not matching up.">]
[<Description "Displays a message in the console, signfying the command-method is working. The command uses F#'s double back-tick notation.">]
[<Parameters "none">]
[<Usage "> test 2 ... or ... > test-2">]
[<Usage "> > test-2">]
let ``test-2``() = "Result: Test 2 working"
(*This works when you enter "test 2" or "test-2".
THIS IS DIFFERENT THaN THE FULL DOT-NET FRAMEWORK VERSION.*)
(* This does work. *)
[<ListCommand>]
[<Description "Displays a message in the console, signfying the command-method is working.">]
[<Parameters "none">]
[<Usage "> test 3">]
let """test 3""" = "Result: Test 3 working"
(*This is not displayed in the help section, regardless of the attributes.
It still works if you enter the command into the console, though.*)
(* This does not work. *)
[<ListCommand>]
[<Description "Displays a message in the console, signfying the command-method is working.">]
[<Parameters "none">]
[<Usage "> test 4">]
let """test-4""" = "Result: Test 4 working"
(* This only works when you type "test 4" not ideal but better then nothing.
This is not displayed in the help section, regardless of the attributes.
It still works if you enter the command in the console, though.*)
(* This does not work. *)

Loading…
Cancel
Save