使用参数列表创建宝石的Gem框架?

时间:2010-08-19 23:02:20

标签: ruby gem

我想在运行时使用参数列表创建一些Gems:my_app --help。

就像所有的宝石(耙子,铁轨等)。

示例:

Usage:
  rails new APP_PATH [options]

Options:
  -J, [--skip-prototype]      # Skip Prototype files
  -T, [--skip-test-unit]      # Skip Test::Unit files
      [--dev]                 # Setup the application with Gemfile pointing to your Rails checkout
  -G, [--skip-git]            # Skip Git ignores and keeps
  -b, [--builder=BUILDER]     # Path to an application builder (can be a filesystem path or URL)
  -m, [--template=TEMPLATE]   # Path to an application template (can be a filesystem path or URL)
      [--edge]                # Setup the application with Gemfile pointing to Rails repository
      [--skip-gemfile]        # Don't create a Gemfile
  -d, [--database=DATABASE]   # Preconfigure for selected database (options: 

通过这种方式,我可以通过以下方式使用它:

gem install my_gem
my_gem --help
my_gem delete files file1.jpg file2.jpg
my_gem update
etc...

是否有某种宝石框架或是否需要从头开始?

1 个答案:

答案 0 :(得分:2)

有很多选择(haaaa ......)

标准的是Ruby的stdlib:http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html

Rails使用Thor,可能更适合您的需求。 http://rubygems.org/gems/thor