I'd like to write a small command line utility in ruby and distribute it as a gem. I know that once installed, certain gems like Guard, Sass and Thor can be run by themselves from the command line.
What do I need to specify in my gemspec in order to have a gem available like a binary.
Press Ctrl twice to invoke the Run Anything popup. Type the ruby script. rb command and press Enter . If necessary, you can specify the required command-line options and script arguments.
How to Use Command-Line Arguments. In your Ruby programs, you can access any command-line arguments passed by the shell with the ARGV special variable. ARGV is an Array variable which holds, as strings, each argument passed by the shell.
To use it, you launch the irb executable and type your Ruby code at the prompt. IRB evaluates the code you type and displays the results. IRB gives you access to all of Ruby's built-in features, as well as any libraries or gems you've installed.
Gem::Specification.new do |s|
...
s.executable = 'name_of_executable'
...
end
http://docs.rubygems.org/read/chapter/20
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With