0

I know how to start ruby-prof with a script:

 ruby-prof -p multi [SCRIPT_PATH]/my_script.rb

but how can I run ruby-prof with a script that takes arguments ?

Mohamed Hakki
  • 88
  • 1
  • 10

1 Answers1

1

Most commands that run another command will let you do this with the special double dash -- option, followed by the arguments you want to pass through. ruby-prof follows this norm.

If you have a Ruby file like this:

# test.rb
puts "ARGV: #{ARGV.inspect}"

You can run ruby-prof like this and get the args:

» ruby-prof test.rb -- arg1 arg2
ARGV: ["arg1", "arg2"]

So in your specific case, you can do this:

» ruby-prof -p multi [SCRIPT_PATH]/my_script.rb -- arg1 arg2
brainbag
  • 1,007
  • 9
  • 23
  • Thank you for your answer @brainbag you were right, I used the Help of the command `ruby-prof -h` and i get help on how to use gem: `Usage: ruby-prof [options] [--] [profiled-script-command-line-options]` So for my example the answer will be: `ruby-prof -p multi [SCRIPT_PATH]/my_script.rb -- --argument1='A' --argument1='B'` – Mohamed Hakki Nov 17 '17 at 14:24