Sha256: 7c7905986a65d5349db0267e546fd70a57cb4d917b47a12aeb39ea76c24cf5fb
Contents?: true
Size: 597 Bytes
Versions: 9
Compression:
Stored size: 597 Bytes
Contents
module VerySafeRm module Arg def self.parse(argv) a = argv.each_with_object(file: [], args: [], done: false) do |arg, obj| if obj[:done] then obj[:file] << arg elsif arg == '--' then obj[:done] = true elsif arg[0] == '-' then obj[:args].push(*Arg.arg(arg)) else obj[:file] << arg end end [a[:file], a[:args]] end private_class_method def self.arg(arg) return [] unless arg[0] == '-' return [arg] if arg[1] == '-' arg[1..-1].each_char.each_with_object([]) { |a, obj| obj << "-#{a}" } end end end
Version data entries
9 entries across 9 versions & 1 rubygems