From cd764ac262578ecc0ca132f6ab80c902f5648f16 Mon Sep 17 00:00:00 2001 From: Michail Merkushin Date: Wed, 22 Mar 2017 11:03:19 +0500 Subject: [PATCH] Fix help duplication --- bin/apress-gem | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/apress-gem b/bin/apress-gem index 2a80689..13ad4d9 100755 --- a/bin/apress-gem +++ b/bin/apress-gem @@ -23,7 +23,7 @@ opt_parser = OptionParser.new do |opt| opt.separator 'Options' opt.on('-h', '--help', 'help') do - puts opt_parser + options[:show_help] = true end opt.on('-v', '--version VERSION', 'new version, ex: -v 1.0.0') do |value| @@ -65,10 +65,14 @@ end opt_parser.parse! -cli = Apress::Gems::Cli.new(options) +if options[:show_help] + puts opt_parser + exit +end -if %w(release changelog build upload tag current bump exist).include?(ARGV[0]) - cli.public_send(ARGV[0]) +subcmd = ARGV[0] +if %w(release changelog build upload tag current bump exist).include?(subcmd) + Apress::Gems::Cli.new(options).public_send(subcmd) else puts opt_parser end