ruby - 将 gem 中的 ruby​​ 脚本添加到路径

标签 ruby rubygems command-line-interface

我刚刚创建了一个非常简单的 ruby​​gem,它只有一个带有几个参数的文件。

我想在安装时自动将此 ruby​​ 脚本添加到路径中,以便我可以从终端中的任何位置使用它,例如:

myruby "param1" "param2"

最佳答案

看看this documentation from RubyGems .

Adding an executable to a gem is a simple process. You just need to place the file in your gem’s bin directory, and then add it to the list of executables in the gemspec. Let’s add one for the Hola gem. First create the file and make it executable:

This article似乎也相当不错,它涵盖了添加可执行文件的基本细节。

关于ruby - 将 gem 中的 ruby​​ 脚本添加到路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20608920/

相关文章:

ruby - 检查 Gemfile.lock 是否匹配 Gemfile

javascript - jquery 显示/隐藏 block 中的 Ruby 变量

ruby-on-rails - 在Gemfile中将插件指定为来自github的gem

ruby - 追溯 Ruby Gmail Gem 方法的源头

scala - 如何处理scala中外部命令的用户交互

命令行界面和过程控制

ruby - 在写入时将 .mov 流式传输到浏览器

ruby - 我可以使用 RVM 为所有用户维护单一版本的 Ruby 吗?

javascript - 使用 node cli 工具作为库 (trim3)

ruby-on-rails - 在 ruby​​ on rails 中选择复选框传递数组