10 Feb 2012, 09:28
Larrycai200200_pragsmall

Larry Cai (8 posts)

Hi:

It is a nice book to concentrate the command line tool, and I have a question when after quickly reading.

In the book, it goes to sample codes directly. And I want to see how to organize the ruby tool in the beginning, like whether we should write like below

#!/usr/bin/env ruby
options handling

def methods
end

def methods
end

def main
end

main

10 Feb 2012, 17:22
Dmfcb_pragsmall

David Copeland (98 posts)

I’m not sure what you mean “in the beginning”, but the book should ultimately describe a format for the bin file that is:

#!/usr/bin/env ruby

def main(args)
 # main logic here
end

def support_method
end

def another_method
end

# parse options

main(ARGV)

Is that what you’re looking for?

12 Feb 2012, 15:56
Larrycai200200_pragsmall

Larry Cai (8 posts)

Thanks.

Yes, this is what I want to, and want to see in the beginning of the book.

And I can’t find your sample and related description when I searched in the ebook (b6_0).

17 Feb 2012, 13:51
Dmfcb_pragsmall

David Copeland (98 posts)

Yeah, I think this is only alluded to in the book; it could probably be better called out, but this post on my blog, while focused on the Methadone CLI library, might give you some more info: http://www.naildrivin5.com/blog/2011/12/19/methadone-the-awesome-cli-library.html

09 Mar 2012, 05:09
Larrycai200200_pragsmall

Larry Cai (8 posts)

even better, start to use the tips

  You must be logged in to comment