开发者

Using thor for complex command line tool

i want to create a command line tool in Ruby using Thor. This tool should be packaged as a gem so that it 开发者_StackOverflow社区is easily installed and uninstalled.

Creating and publishing the gem, I have done. I also created several Thor scripts which also work. However, I do not know how to combine them.

My aim is to be able to call my tool the following way: mytool task param --options mytool taskgroup:task param --options

I know how to make one Thor script to be executable. However, how do I make a bunch of thor scripts accessible throw one command?


According to the relevant Gem documentation, you could specify (in your .gemspec):

spec.executables = ['bin/foo', 'bin/bar']
spec.default_executable = 'bin/bar'

and have your gem install a bunch of executables (foo and bar). Or you write a wrapper for all your Thor scripts and specify:

spec.executables = ['bin/wrapper']

and have your gem install only one executable (wrapper).


The teletype gem (https://github.com/piotrmurach/tty) does an amazing job at setting up all the scaffolding for this. Create your project with teletype and then just fill in the implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜