Comments at end.

On Tue, 17 Aug 2010 18:04:02 -0700, Rein Henrichs wrote:
> 
> Simplify the binary by moving all application specific code into a new
> Facter::Application module. This module is then refactored to use
> OptionParser and to simplify invocation logic, while maintaining
> existing behavior.
> 
> Signed-off-by: Rein Henrichs <[email protected]>
> ---
>  bin/facter                |  135 
> ++++-----------------------------------------
>  lib/facter/application.rb |   99 +++++++++++++++++++++++++++++++++
>  2 files changed, 111 insertions(+), 123 deletions(-)
>  create mode 100644 lib/facter/application.rb
> 
> diff --git a/bin/facter b/bin/facter
> index a6cb717..328d5fc 100755
> --- a/bin/facter
> +++ b/bin/facter

*snip*

> -
> -$haveusage = true
> -
> -begin
> -    require 'rdoc/ri/ri_paths'
> -    require 'rdoc/usage'
> -rescue Exception
> -    $haveusage = false
> -end
> -

*snip*

> -        when "--help"
> -            if $haveusage
> -                RDoc::usage && exit
> -            else
> -                puts "No help available unless you have RDoc::usage 
> installed"
> -                exit
> -            end
> -        else

*snip*

> diff --git a/lib/facter/application.rb b/lib/facter/application.rb
> new file mode 100644
> index 0000000..51dbd14
> --- /dev/null
> +++ b/lib/facter/application.rb

*snip*

> +        opts.on_tail("-h", "--help") do
> +          begin
> +            require 'rdoc/ri/ri_paths'
> +            require 'rdoc/usage'
> +            puts RDoc.usage
> +          ensure
> +            exit
> +          end
> +        end

*snip*

I don't really like that we need to separate the documentation of the
options from the file where we actually specify the available options,
but I understand that this is a limitation of RDoc::usage.

As for all the *snip*ing above: The warning message about help not being
available without RDoc::usage being installed was lost in moving the
logic, and behavior to its own module.  Was this intentional?

Also: It'd be nice to have some tests now that this is a proper module.
;-)

-- 
Jacob Helwig

Attachment: signature.asc
Description: Digital signature

Reply via email to