ruby / ruby/rake

Can't pass parameters to rake task

Open
#42 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.5k
Forks
650
Avg merge
6m
Merged PRs (30d)
3

Description

I have this task:

desc 'Tests input parameters'
task :params do |args|
  options = {}
  OptionParser.new(args) do |opts|
    opts.banner = "Usage: rake params [options]"
    opts.on("-F", "--file {file}", "A file", String) do |file|
      options[:file] = file
    end
  end.parse!
  puts options.inspect.green
end
rake params -- -Fmy_file.txt

In rake 10.3.x I receive:

{:file => "my_file.txt"}

In rake 10.4.x I receive:

{}

Why?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing rake params -- -Fmy_file.txt against Rake 10.3.x and 10.4.x, then trace how task arguments are passed to the OptionParser entry point. Done means explaining the version difference and covering the regression with a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.