require 'optparse' class Test class CLI def parse_options(argv = ARGV) op = OptionParser.new # op ããã¼ã«ã«å¤æ°ãªã®ã§ `define_method` 㧠`usage` ãå®ç¾©ãã¦ãããããã ã®ãã ããã«éããªãã¨è¨ãã°ãã®éã self.class.module_eval do define_method(:usage) do |msg = nil| puts op.to_s puts "error: #{msg}" if msg exit 1 end end # default value opts = { boolean: false, string: '', integer: 0, array: [], } # boolean op.on('-b', '--[no-]boolean'
{{#tags}}- {{label}}
{{/tags}}