Class: Bun::Arguments
- Inherits:
-
Object
- Object
- Bun::Arguments
- Defined in:
- lib/bun/arguments.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
-
#optimistic ⇒ Object
(also: #optimistic?)
Returns the value of attribute optimistic.
-
#print ⇒ Object
(also: #print?)
Returns the value of attribute print.
-
#skip_install ⇒ Object
(also: #skip_install?)
Returns the value of attribute skip_install.
-
#strict ⇒ Object
(also: #strict?)
Returns the value of attribute strict.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(arguments) ⇒ Arguments
constructor
A new instance of Arguments.
- #parse ⇒ Object
Constructor Details
#initialize(arguments) ⇒ Arguments
Returns a new instance of Arguments.
5 6 7 |
# File 'lib/bun/arguments.rb', line 5 def initialize(arguments) @arguments = arguments end |
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
9 10 11 |
# File 'lib/bun/arguments.rb', line 9 def group @group end |
#optimistic ⇒ Object Also known as: optimistic?
Returns the value of attribute optimistic.
9 10 11 |
# File 'lib/bun/arguments.rb', line 9 def optimistic @optimistic end |
#print ⇒ Object Also known as: print?
Returns the value of attribute print.
9 10 11 |
# File 'lib/bun/arguments.rb', line 9 def print @print end |
#skip_install ⇒ Object Also known as: skip_install?
Returns the value of attribute skip_install.
9 10 11 |
# File 'lib/bun/arguments.rb', line 9 def skip_install @skip_install end |
#strict ⇒ Object Also known as: strict?
Returns the value of attribute strict.
9 10 11 |
# File 'lib/bun/arguments.rb', line 9 def strict @strict end |
Instance Method Details
#empty? ⇒ Boolean
16 17 18 |
# File 'lib/bun/arguments.rb', line 16 def empty? @arguments.empty? end |
#parse ⇒ Object
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 54 55 56 57 58 59 60 61 62 |
# File 'lib/bun/arguments.rb', line 20 def parse opt_parser = OptionParser.new do |opts| opts. = Bun::Messages::USAGE opts.on("-P", "--print", "# Just print the gem name and version and exit.") do self.print = true end opts.on("-o", "--optimistic", "# Use optimistic version range >= instead of ~>.") do self.optimistic = true end opts.on("-S", "--strict", "# Use strict version instead of ~> range.") do self.strict = true end opts.on("-d", "--development", "# Add gem to development group.") do self.group = :development end opts.on("-t", "--test", "# Add gem to test group.") do self.group = :test end opts.on("-s", "--skip-install", "# Skip the install step.") do self.skip_install = true end opts.on_tail("-h", "--help", "# Print these usage instructions.") do puts opts end opts.on("-v", "--version", "# Show current Bun version.") do puts Bun::VERSION end end begin opt_parser.parse(arguments) rescue OptionParser::InvalidOption puts opt_parser end end |