cldwalker / boson

A command/task framework similar to rake and thor built with extendability in mind.
http://rdoc.info/gems/boson
MIT License
218 stars 10 forks source link

Turn a module into an executable by just requiring boson? #3

Closed jeroenvandijk closed 14 years ago

jeroenvandijk commented 14 years ago

First, thanks for this great library.

I'm currently trying to make a simple command line utility of a simple ruby module ( see this gist http://gist.github.com/259360 )

I would like to just require boson and make it an executable. I think it shouldn't be a lot of work given what you already can do with boson. Maybe it is already possible?

Do you have suggestions?

Cheers, Jeroen

cldwalker commented 14 years ago

Repasting from private message for benefit of others:

Hi jeroenvandijk, I forked the gist and gave some examples of how to use it at the end: http://gist.github.com/259392

Since you're only calling one method, there's no need to use Boson's commands. I simply used its option parser. (Documentation on the option parser)[http://tagaholic.me/boson/doc/classes/Boson/OptionParser.html]. At some point I should move Boson's option parser into a separate gem. I consider it more efficient and powerful than trollop

cldwalker commented 14 years ago

Repasted in response to wanting the gist to handle multiple commands:

This should handle multiple commands while providing basic help and error handling: http://gist.github.com/265007 Notice that I had to modify Example to provide class-level methods (extend self) and that I had to define options and argument sizes when loading with Manager.load

cldwalker commented 14 years ago

Feel free to reopen if you're still having issues with this.

hedgehog commented 13 years ago

The issue I'm having with this is I see:

The following commands conflict with existing commands: features, specs. Attempting load into the namespace bdd...
Error: No method exists to redefine command 'features'.

With this example, which correctly prases the options given: https://gist.github.com/867668

If I remove the self, I don't see the error, but the options are not correctly parsed.

Options used are in that gist.