lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2013/3/23 oliver <oliver.schoenborn@gmail.com>:
> I'm going to need something like this in bluash (on github). Did you just
> "whip this up" or is it part of a project I can "require" from bluash?

It's not mindblowingly original, and my original intention was that you
could just cut-and-paste the code into your own code and modify the
definitions of shorthelp and longhelp. The Lua MIT license is quite
permissive, I think you would just need to acknowledge where you got it.
I don't want to document it separately -- it's basically
self-documenting -- and I don't want the hassle of formally publishing
it as a module I would feel obliged to maintain. That's why I simply
included the source in a post to lua-l. Maybe I should put it on the Lua
Wiki.

But it would certainly be easier to use from anywhere if you turned it
into a module. That's quite easy:

1. Remove the lines defining 'shorthelp' and 'longhelp'.
2. Change `help = function(fct)` to `local help = function(fct)`.
3. At the bottom, just before the final 'end', add "return help".
4. If you are a purist, remove the enlosing "do" .. "end".
5. Put 'help.lua' anywhere in your package.path.

Then you use it this way:

do
  local shorthelp = 'short help text'
  local longhelp = {topic=text,...}
  help=require"help"'
end