0

I'm working on simple script that setup project structure for me (directories/files). I have an issue with retrieving argument passed as command line argument:

#!/usr/bin/env ruby

project_name = ARGV.first

puts "Provide project name" ; abort if project_name.nil?

When I try to run it, I get:

$ ./creator test
Provide project name

May be I'm not aware of something. When I do without #!/usr/bin/env ruby it works perfect.

1 Answer 1

1

Your problem has nothing to do with wether you execute your script with $ ./creator test or $ ruby creator test. The problem is that you always just print a static string with puts "Provide project name". I think this is more what you are after:

#!/usr/bin/env ruby
project_name = ARGV.first
abort if project_name.nil?
puts "Provide #{project_name}"

Here the project_name variable is substituted into the string, by doing #{project_name}.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.