edit The Help Attributes.

master
Craig Oates 5 years ago
parent
commit
08fa4973a0
  1. 16
      The-Help-Attributes.md

16
The-Help-Attributes.md

@ -1,9 +1,9 @@
To use the "Help Section" feature, you will need to know about the four attributes it is built with. They are as follows,
- **ListCommand**: When you attach this attribute to a command-method, that method will appear in the help section at run-time. You can, also, pass in a false Boolean, as a parameter. This explicit declaration means the method will not appear at run-time. I use this option to turn things on an off without needing to rewrite the whole line every time. It helps with reducing temporary comment code, as well.
- **Parameters**: You can use this attribute to list out the parameters the end-user will need to pass into the command-method. The reason why you need to pass in a string to the attributes constructor is so you have flexibility. Some methods have parameter lists which are large and difficult to read. Because of this, it is in your end-user's interest for you to simplify it. I admit I could have programmed Console.Waterworks to figure it out for you. But, that would have taken that decision away from you. Whilst it is not perfect, I believe the string approach is the most practical solution.
- **Describe**: This attribute allows you to offer contextual information to the end-user. To use it, you pass in a string to the attribute's constructor.
- **Usage**: To help your end-users even more, you can provide them with an example of how to use your command-methods. To use this attribute, pass in a string to its constructor.
- **ListCommand**: When you attach this attribute to a command-method, that method will appear in the help section at run-time. You can, also, pass in `false`, as a parameter. This explicit declaration means the method will not appear at run-time. I use this option to turn things on an off without needing to rewrite the whole line every time. It helps with reducing temporary comment code, as well.
- **Parameters**: You can use this attribute to list out the parameters the end-user will need to pass into the command-method. The reason why you need to pass in a `string` to the attributes constructor is so you have flexibility. Some methods have parameter lists which are large and difficult to read. Because of this, it is in your end-user's interest for you to simplify it. I admit I could have programmed Console.Waterworks to figure it out for you. But, that would have taken that decision away from you. Whilst it is not perfect, I believe the string approach is the most practical solution.
- **Describe**: This attribute allows you to offer contextual information to the end-user. To use it, you pass in a `string` to the attribute's constructor.
- **Usage**: To help your end-users even more, you can provide them with an example of how to use your command-methods. To use this attribute, pass in a `string` to its constructor.
To you get a sense of how they look in practice, please use the links below:
@ -12,3 +12,11 @@ To you get a sense of how they look in practice, please use the links below:
- [Smouldering Beach Ball's ConsoleCommands.fs](https://gitlab.com/craig.oates/Smouldering-Beach-Ball/blob/master/SmoulderingBeachBallCLI/ConsoleCommands.fs) (this uses the attributes with F#)
You will only see these attributes decorating command-methods found in each project's "ConsoleCommands.cs" file (or ConsoleCommands.fs" file if you're using F#).
```c#
// Copy and paste this in to ConsoleCommands file to speed up the typing.
[ListCommand()] // Passing in no parameters defaults to true.
[Description("")]
[Parameters("")]
[Usage("> ")]
```

Loading…
Cancel
Save