Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass a string with space in argument #3

Closed
flagos opened this issue Jun 27, 2011 · 3 comments
Closed

How to pass a string with space in argument #3

flagos opened this issue Jun 27, 2011 · 3 comments
Labels

Comments

@flagos
Copy link

flagos commented Jun 27, 2011

Hi,

I use your library to parse my ARGV. I didn't find the way to manage the case of having a argument with a message, such as:
myscript.rb -m "my smart release note"

Is there a way to cover this case with µ-optparse?

If no, I see in code your lib is a wrapper to OptionParser which has #separator and #record_separator attributes. Maybe there is a way to access to it ?

@florianpilz
Copy link
Owner

Currently this is not possible with micro-optparse. At the moment I have no time to investigate how to accomplish that in general and even if it would be possible, it depends on the number of lines to add for this functionality. If it is 'too much', a fork with more features would be the best solution.

If you want to experiment a little bit by yourself go ahead and tell me what you found or make a branch so I can see the changes. Otherwise I will have more time in around 4 weeks, I will dig into it then by myself.

Hope this information helps. :)

@florianpilz
Copy link
Owner

I was wrong - arguments with spaces in them are supported. Just define an option which takes a String as an argument and you are ready to go.

Example Script:

require 'rubygems' # necessary for ruby v1.8.*
require 'micro-optparse'

options = Parser.new do |p|
  p.option :sentence, "Files which will be processed", :default => ""
end.process!

p options

Example Usage:

ruby temp.rb -s 'Hello World! You can even, if you want to, use commas.'
=> {:sentence=>"Hello World! You can even, if you want to, use commas."}

PS: Sorry for my late response. Was fun digging into OptionParser again and even more fun that µ-optparse is more powerful than I thought. I hope this answers your question, if not, feel free to ask. :)

@flagos
Copy link
Author

flagos commented Oct 18, 2011

Good news ! This was exactly my issue, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants