lib/configliere/commandline.rb in configliere-0.4.18 vs lib/configliere/commandline.rb in configliere-0.4.22
- old
+ new
@@ -10,27 +10,31 @@
attr_accessor :rest
attr_accessor :description
attr_reader :unknown_argvs
# Processing to reconcile all options
- #
- # Configliere::Commandline's resolve!:
- #
+ #
# * processes all commandline params
- # * if the --help param was given, prints out a usage statement describing all #define'd params and exits
# * calls up the resolve! chain.
#
- def resolve!
+ # * if the --help param was given, prints out a usage statement describing all #define'd params and exits
+ #
+ # If the --help param was given, Will print out a usage statement
+ # describing all #define'd params and exit. To avoid this, pass
+ # `false` as the first argument.
+ #
+ # @param [true,false] print_help_and_exit whether to print help and exit if the --help param was given
+ def resolve!(print_help_and_exit=true)
process_argv!
- if self[:help]
+ if print_help_and_exit && self[:help]
dump_help
exit(2)
end
super()
self
end
-
+
#
# Parse the command-line args into the params hash.
#
# '--happy_flag' produces :happy_flag => true in the params hash
# '--foo=foo_val' produces :foo => 'foo_val' in the params hash.
@@ -135,9 +139,10 @@
# Usage line
def usage
%Q{usage: #{raw_script_name} [...--param=val...]}
end
+ attr_writer :usage
# the script basename, for recycling into help messages
def raw_script_name
File.basename($0)
end