Class: Kubetailrb::OptsParser
- Inherits:
-
Object
- Object
- Kubetailrb::OptsParser
- Defined in:
- lib/kubetailrb/opts_parser.rb
Overview
Parse CLI arguments and flags. NOTE: We could use the standard library optparse (OptionParser) or a more comprehensive tool like Thor to achieve this, but that would defeat the purpose of learning by implementing it ourselves.
Instance Method Summary collapse
-
#initialize(*args) ⇒ OptsParser
constructor
A new instance of OptsParser.
- #parse ⇒ Object
Constructor Details
#initialize(*args) ⇒ OptsParser
Returns a new instance of OptsParser.
14 15 16 |
# File 'lib/kubetailrb/opts_parser.rb', line 14 def initialize(*args) @args = *args end |
Instance Method Details
#parse ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/kubetailrb/opts_parser.rb', line 18 def parse return Cmd::Help.new if Cmd::Help.applicable?(*@args) return Cmd::Version.new if Cmd::Version.applicable?(*@args) return Cmd::File.create(*@args) if Cmd::File.applicable?(*@args) Cmd::K8s.create(*@args) end |