I built a LaTeX preprocessor in Ruby called Vanilla. It provides a command line tool called vanilla
, which uses Optparse
to parse some command line options. I used the OCRA
gem to compile it into an exe, which is only helpful on Windows. I want to do the same for Mac and possibly Linux. I know that Mac computers ship with Ruby and you can call ruby vanilla.rb some options
to achieve what I want. But I am looking for a native way so that I can do vanilla some options
in a terminal. Can anyone help me find any good tutorials on achieving this?
我在Ruby中构建了一个名为Vanilla的LaTeX预处理器。它提供了一个名为vanilla的命令行工具,它使用Optparse来解析一些命令行选项。我使用OCRA gem将其编译成exe,这只对Windows有用。我想为Mac和Linux做同样的事情。我知道Mac计算机附带Ruby,你可以调用ruby vanilla.rb来实现我想要的一些选项。但我正在寻找一种本地方式,以便我可以在终端中为香草做一些选择。任何人都可以帮我找到任何有关实现这一目标的好教程吗?
2 个解决方案
#1
1
move the script to a folder named bin
in your project directory, and take off the .rb
from it. At the top of the file, put in #!/usr/bin/env ruby
. You're done!
将脚本移动到项目目录中名为bin的文件夹,然后从中取出.rb。在文件的顶部,输入#!/ usr / bin / env ruby。你完成了!
#2
2
In Unix shells, the names of executables are looked up in a list of directories specified by the PATH
environment variable. So, if you make your script executable and put it somewhere in the user's PATH
, they'll be able to run it just like any other utility.
在Unix shell中,可执行文件的名称在PATH环境变量指定的目录列表中查找。因此,如果您使脚本可执行并将其放在用户PATH中的某个位置,那么它们就能像其他任何实用程序一样运行它。
#1
1
move the script to a folder named bin
in your project directory, and take off the .rb
from it. At the top of the file, put in #!/usr/bin/env ruby
. You're done!
将脚本移动到项目目录中名为bin的文件夹,然后从中取出.rb。在文件的顶部,输入#!/ usr / bin / env ruby。你完成了!
#2
2
In Unix shells, the names of executables are looked up in a list of directories specified by the PATH
environment variable. So, if you make your script executable and put it somewhere in the user's PATH
, they'll be able to run it just like any other utility.
在Unix shell中,可执行文件的名称在PATH环境变量指定的目录列表中查找。因此,如果您使脚本可执行并将其放在用户PATH中的某个位置,那么它们就能像其他任何实用程序一样运行它。