Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mookid8000 committed Oct 25, 2015
1 parent 3ef4647 commit ba01396
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Beverage/Commands/WhiteRussian.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class WhiteRussian : ICommand

public void Run()
{
Console.WriteLine($"Making a {(LukeWarm ? "luke-warm" : "")} beverage with {Vodka:0.#} cl of vodka and {Kahlua:0.#} cl of Kahlua");
Console.WriteLine($"Making a {(LukeWarm ? "luke-warm" : "")} beverage" +
$" with {Vodka:0.#} cl of vodka" +
$" and {Kahlua:0.#} cl of Kahlua");
}
}
}
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,109 @@ And then you decorate the command class and the parameter properties with `[Desc

And then you add a couple of `[Example]` to some of the parameter properties, just to be nice.

Example!
====

This is the `white-russian` command in a fictive Beverage utility:


[Command("white-russian")]
[Description("Mixes a White Russian, pouring in milk till full")]
public class WhiteRussian : ICommand
{
[Parameter("vodka")]
[Description("How many cl of vodka?")]
public double Vodka { get; set; }

[Parameter("kahlua")]
[Description("How many cl of Kahlua?")]
public double Kahlua { get; set; }

[Parameter("lukewarm", optional: true)]
[Description("Avoid refrigerated ingredients?")]
public bool LukeWarm { get; set; }

public void Run()
{
Console.WriteLine($"Making a {(LukeWarm ? "luke-warm" : "")} beverage" +
$" with {Vodka:0.#} cl of vodka" +
$" and {Kahlua:0.#} cl of Kahlua");
}
}

If you invoke it without its command, it will print out the available commands:

C:\> beverage.exe

------------------------------
Beverage Utility

Copyright (c) 2015 El Duderino
------------------------------
Please invoke with a command - the following commands are available:

white-russian - Mixes a White Russian, pouring in milk till full

Invoke with -help <command> to get help for each command.

Exit code: -1

and then, if you add `-help white-russian` as an argument, you'll get detailed help for that command:

C:\> beverage.exe -help white-russian

------------------------------
Beverage Utility

Copyright (c) 2015 El Duderino
------------------------------
Mixes a White Russian, pouring in milk till full

Type

Beverage.exe white-russian <args>

where <args> can consist of the following parameters:

-vodka
How many cl of vodka?

-kahlua
How many cl of Kahlua?

-lukewarm (flag/optional)
Avoid refrigerated ingredients?

If you try to invoke a command, and one or more of the arguments are missing, you'll know:

C:\> beverage white-russian -vodka 1

------------------------------
Beverage Utility

Copyright (c) 2015 El Duderino
------------------------------
The following required parameters are missing:

-kahlua - How many cl of Kahlua?

Invoke with -help <command> to get help for each command.

Exit code: -1

and then, when you finally invoke the command with the right arguments, it'll run as you would probably expect:

C:\> beverage white-russian -vodka 2 -kahlua 2

------------------------------
Beverage Utility

Copyright (c) 2015 El Duderino
------------------------------
Making a beverage with 2 cl of vodka and 2 cl of Kahlua

Neat.

License
====

Expand Down

0 comments on commit ba01396

Please sign in to comment.