davetron5000 / gli

Make awesome command-line applications the easy way
http://davetron5000.github.io/gli
Apache License 2.0
1.26k stars 102 forks source link

Flag value left blank results in printing help for main instead of command #234

Open manther opened 8 years ago

manther commented 8 years ago

In the following example if you call the command "init -n" and don't pass a value for "-n" GLI prints the main help for the entire application instead of printing the help for the command that was being called "init"

#!/usr/bin/env ruby
require 'gli'
require 'json'
include GLI::App

program_desc 'Describe your application here'

version Testit::VERSION

subcommand_option_handling :normal
arguments :strict

command :init do |c|
  c.flag :n,
         :type     => String,
         :desc     => 'Name',
         :required => true
  c.action do |_, _, _|
    puts "test"
  end
end
davetron5000 commented 8 years ago

Yup, looks like a bug :(

manther commented 8 years ago

Thank you for looking into it.

davetron5000 commented 1 month ago

See #326 as this is related. I believe this is OptionParser behavior which may be difficult to unwind or change. Leaving open as documentation