summaryrefslogtreecommitdiff
path: root/lib/slop.rb
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2014-11-18 22:16:20 +0000
committerLee Jarvis <ljjarvis@gmail.com>2014-11-18 22:29:15 +0000
commite78399b4841d709ccc02de14c583f92ef8a649ff (patch)
tree012575c9523f7e8ba712d8421f189e0aec5ed65e /lib/slop.rb
parentc67a27c4b7554cbf66536e5bcebed60ff4cc7feb (diff)
downloadslop-e78399b4841d709ccc02de14c583f92ef8a649ff.tar.gz
Start of rewrite
Diffstat (limited to 'lib/slop.rb')
-rw-r--r--lib/slop.rb52
1 files changed, 9 insertions, 43 deletions
diff --git a/lib/slop.rb b/lib/slop.rb
index 2a5546f..bf16b5c 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -1,51 +1,17 @@
-require 'slop/commands'
-require 'slop/command'
-require 'slop/option_builder'
-require 'slop/processor'
-require 'slop/options'
require 'slop/option'
-require 'slop/error'
-
-class Slop
- VERSION = "4.0.0"
-
- class << self
- attr_accessor :config
- end
-
- self.config = {
- strict: true,
- help: true,
- ignore_case: false,
- multiple_switches: true
- }
-
- def self.parse!(items = ARGV, config = {}, &block)
- Slop.new(config, &block).parse!(items)
- end
-
- def self.parse(items = ARGV, config = {}, &block)
- parse!(items.dup, config, &block)
- end
-
- attr_reader :command
+require 'slop/options'
+require 'slop/types'
- def initialize(config = {}, &block)
- @command = Command.new(:_global_, config, &block)
+module Slop
+ def self.option_defined?(name)
+ const_defined?(string_to_option(name.to_s))
end
- # Delegate methods to command object
-
- def respond_to_missing?(meth, include_private = false)
- command.respond_to_missing?(meth) || super
+ def self.string_to_option(s)
+ s.gsub(/(?:^|_)([a-z])/) { $1.capitalize } + "Option"
end
- def method_missing(meth, *args, &block)
- if command.respond_to?(meth)
- command.public_send(meth, *args, &block)
- else
- super
- end
+ def self.string_to_option_class(s)
+ const_get(string_to_option(s))
end
-
end