class Ghundle::OptionsParser
Contains the logic for extracting command-line options. Relies on ‘optparse’ from the standard library.
Public Class Methods
new(args)
click to toggle source
# File lib/ghundle/options_parser.rb, line 9 def initialize(args) @args = args end
Public Instance Methods
parse()
click to toggle source
# File lib/ghundle/options_parser.rb, line 33 def parse options = OpenStruct.new parser = OptionParser.new do |o| o.banner = usage o.on_tail("-h", "--help", "Show this message") do puts o exit end o.on_tail("--version", "Show version") do puts VERSION exit end end parser.parse!(@args) options end
usage()
click to toggle source
# File lib/ghundle/options_parser.rb, line 13 def usage [ '', 'Usage: ghundle <command> [options...]', '', 'Commands:', '', ' ghundle list-all', ' ghundle run <hook-name>', ' ghundle fetch github.com/<username>/<repo>/<path/to/hook/dir>', ' ghundle install <hook-name>', ' ghundle install github.com/<username>/<repo>/<path/to/hook/dir>', ' ghundle list-installed', ' ghundle uninstall <hook-name>', '', 'Options:', '', ].join("\n") end