lib/hobo/patches/slop.rb in hobo-inviqa-0.0.6 vs lib/hobo/patches/slop.rb in hobo-inviqa-0.0.7.pre.rc1
- old
+ new
@@ -1,9 +1,9 @@
require 'slop'
class Slop
- attr_accessor :long_desc, :arg_list, :hidden, :desc
+ attr_accessor :long_desc, :arg_list, :hidden, :desc, :unparsed
# Slop has a description method but it uses @config which is inherited
# This is not desired behaviour
def description desc = nil
@desc = desc if desc
@@ -27,6 +27,25 @@
def project_only value = nil
@config[:project_only] = value unless value.nil?
@config[:project_only]
end
-end
\ No newline at end of file
+
+ alias :old_parse! :parse!
+ def parse!(items = ARGV, &block)
+ if @unparsed.nil?
+ split_index = items.index('--')
+
+ unparsed = []
+ unless split_index.nil?
+ unparsed = items.slice(split_index + 1, items.length)
+ items = items.slice(0, split_index)
+ end
+
+ @unparsed = unparsed.map do |c|
+ "\'#{c.gsub("'", '\\\'').gsub('(', '\\(').gsub(')', '\\)')}\'"
+ end.join(' ')
+ end
+
+ old_parse!(items, &block)
+ end
+end