Class: Teamocil::OptionParser
- Inherits:
-
Object
- Object
- Teamocil::OptionParser
- Defined in:
- lib/teamocil/utils/option_parser.rb
Instance Method Summary collapse
-
#initialize(arguments: nil) ⇒ OptionParser
constructor
A new instance of OptionParser.
- #parsed_options ⇒ Object
-
#parser ⇒ Object
rubocop:disable MethodLength.
Constructor Details
#initialize(arguments: nil) ⇒ OptionParser
Returns a new instance of OptionParser.
3 4 5 6 |
# File 'lib/teamocil/utils/option_parser.rb', line 3 def initialize(arguments: nil) @arguments = arguments @parsed_options = {} end |
Instance Method Details
#parsed_options ⇒ Object
8 9 10 11 12 |
# File 'lib/teamocil/utils/option_parser.rb', line 8 def @parsed_options.tap do parser.parse!(@arguments) end end |
#parser ⇒ Object
rubocop:disable MethodLength
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/teamocil/utils/option_parser.rb', line 15 def parser ::OptionParser.new do |parser| parser. = 'Usage: teamocil [options] <layout>' parser.separator '' parser.separator 'Specific options:' # Global options parser.on('--list', 'List all available layouts in `~/.teamocil/`') do @parsed_options[:list] = true end # Single layout options parser.on('--here', 'Set up the first layout window in the current tmux window') do @parsed_options[:here] = true end parser.on('--layout [layout]', 'Use a specific layout file, instead of `~/.teamocil/<layout>.yml`') do |layout| @parsed_options[:layout] = layout end parser.on('--edit', 'Edit the YAML layout file instead of using it') do @parsed_options[:edit] = true end parser.on('--show', 'Show the content of the layout file instead of executing it') do @parsed_options[:show] = true end # Debug options parser.on('--debug', 'Show the commands Teamocil will execute instead of actually executing them') do @parsed_options[:debug] = true end parser.on('--version', '-v', 'Show Teamocil’s version number') do Teamocil.puts(VERSION) exit end end end |