Created
January 14, 2018 07:21
-
-
Save bleis-tift/84ea0e705daff0d5237e457ba939209b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CommandInfo = | |
{ Names: string[] | |
Summary: string | |
Syntax: string | |
Help: string option } | |
type CommandWrapper(info: CommandInfo, proc: string -> unit) = | |
inherit Command() | |
override __.Names = info.Names | |
override __.Summary = info.Summary | |
override __.Syntax = info.Syntax | |
override __.Help = | |
match info.Help with | |
| Some help -> help | |
| None -> base.Help | |
override __.Process(args) = proc args | |
[<Sealed; Command>] | |
type MultiCommandWrapper(info: CommandInfo, commands: Command list) = | |
inherit MultiCommand() | |
do | |
for cmd in cmds do | |
base.AddCommand(cmd) | |
override __.Names = info.Names | |
override __.Summary = info.Summary | |
override __.Syntax = info.Syntax | |
override __.Help = | |
match info.Help with | |
| Some help -> help | |
| None -> base.Help | |
let helloWorldCmd = | |
let info = | |
{ Names = [|"bbbcmd"|] | |
Summary = "aaa bbb ccc" | |
Syntax = "ddd eee fff" | |
Help = Some "help help help" } | |
CommandWrapper(info, args -> Log.Info("hello world from bbbcmd")) | |
let myCommand = | |
let info = | |
{ Names = [|"aaacmd"|] | |
Summary = "aaaaaaaaaaa" | |
Syntax = "bbbbbbbbbbb" | |
Help = Some "cccccccccccccc" } | |
MultiCommandWrapper(info, [helloWorldCmd]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment