mendelt / cmdr

Cmdr is a library for building line-oriented text-based user interfaces in Rust.
Apache License 2.0
15 stars 1 forks source link

Update the help function to allow showing custom help text for each command #3

Closed mendelt closed 5 years ago

mendelt commented 5 years ago

The help or ? function should show custom help text for a command when called with a command name.

I see three ways this can be implemented;

  1. Like in Python Cmd where a do_command can have an associated help_command method that prints out the help tekst
  2. Another way might be to have the cmdr macro parse the doc-comments for functions and use these as help tekst. Although this seems a bit 'magic' and might interfere how a user of the cmdr library wants to write documentation.
  3. A third way is to annotate do_command with a help 'macro' that is picked up by the cmdr macro.

At the moment I lean towards implementing both option 1 and 3. Normally help methods will be used. Later an extra option can be implemented to easilly implement help methods with static text by using an annotiation.