Module: GitProc::GitProcessOptions
- Defined in:
- lib/git-process/git_process_options.rb
Constant Summary collapse
- DEBUG =
false
Instance Method Summary collapse
- #description ⇒ Object
- #empty_argv_ok? ⇒ Boolean
-
#extend_opts(parser) ⇒ Object
noinspection RubyUnusedLocalVariable.
- #parse_cli(filename, argv) ⇒ Object
-
#post_parse(opts, argv) ⇒ Object
noinspection RubyUnusedLocalVariable.
- #standard_opts(parser) ⇒ Object
- #summary ⇒ Object
- #usage(filename) ⇒ Object
Instance Method Details
#description ⇒ Object
78 79 80 |
# File 'lib/git-process/git_process_options.rb', line 78 def description 'Default description' end |
#empty_argv_ok? ⇒ Boolean
83 84 85 |
# File 'lib/git-process/git_process_options.rb', line 83 def empty_argv_ok? true end |
#extend_opts(parser) ⇒ Object
noinspection RubyUnusedLocalVariable
89 90 91 |
# File 'lib/git-process/git_process_options.rb', line 89 def extend_opts(parser) # extension point - does nothing by default end |
#parse_cli(filename, argv) ⇒ Object
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 |
# File 'lib/git-process/git_process_options.rb', line 24 def parse_cli(filename, argv) parser = Trollop::Parser.new parser.version "#{filename} #{GitProc::Version::STRING}" #parser.banner "#{summary}\n\n" command_name = filename.sub(/git-/, '') parser. "For full documentation, see 'git help #{command_name}'" parser. "" extend_opts(parser) standard_opts(parser) #parser.banner "\n#{description}" opts = Trollop::with_standard_exception_handling parser do raise Trollop::HelpNeeded if ARGV.empty? and !empty_argv_ok? parser.parse argv end opts[:info] = false if opts[:verbose] || opts[:quiet] opts[:info] = true if opts[:info_given] post_parse(opts, argv) if DEBUG puts "\n\n#{opts.map { |k, v| "#{k}:#{v}" }.join(', ')}" puts "\nargs: #{argv.join(', ')}" end opts end |
#post_parse(opts, argv) ⇒ Object
noinspection RubyUnusedLocalVariable
95 96 97 |
# File 'lib/git-process/git_process_options.rb', line 95 def post_parse(opts, argv) # extension point - does nothing by default end |
#standard_opts(parser) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/git-process/git_process_options.rb', line 57 def standard_opts(parser) parser.opt :info, 'Informational messages; show the major things this is doing', :default => true, :short => :none parser.opt :quiet, 'Quiet messages; only show errors', :short => :q parser.opt :verbose, 'Verbose messages; show lots of details on what this is doing', :short => :v parser.opt :version, "Print version (#{GitProc::Version::STRING}) and exit", :short => :none parser.opt :help, 'Show this message', :short => :h parser.conflicts :verbose, :info, :quiet end |
#summary ⇒ Object
68 69 70 |
# File 'lib/git-process/git_process_options.rb', line 68 def summary 'Default summary' end |
#usage(filename) ⇒ Object
73 74 75 |
# File 'lib/git-process/git_process_options.rb', line 73 def usage(filename) "#{filename} [options]" end |