Skip to content

Releases: davetron5000/gli

v2.12.0

30 Jul 01:15
Compare
Choose a tag to compare
  • Support for "strict" argument parsing. That is, when you specify:

    arg :url

    GLI will check if that arg was given on the command line, and generate an error if not. Note that by default, existing apps will not get this feature without adding arguments :strict to their binfile. Newly-scaffolded apps will have this by default. Thanks @calestar (see #187)

v2.11.0

09 Jun 16:23
Compare
Choose a tag to compare

These features and fixes brought to you by the conscientious @calestar! Many thanks!

  • New Feature - document multiple arguments by repeated calls to arg

    # previously
    arg_name "src dest [second_dest]"
    
    # currently
    arg :src
    arg :dest
    arg :second_dest, :optional

    This doesn't enforce required v optional, but paves the way for it, and makes it easier to build up the arguments help string (see #184 and #180, and http://davetron5000.github.io/gli/rdoc/classes/GLI/DSL.html#method-i-arg)

  • Better help output when multiple required flags are omitted (see #177 and #182)

  • Getting help with GLI_DEBUG set no longer exits nonzero (getting help without GLI_DEBUG set previously exited zero, so this makes the behavior of getting help more consistent. See #183 and #181. Thanks @calestar!)

v2.10.0

22 Apr 12:46
Compare
Choose a tag to compare
  • New option, hide_commands_without_desc which, if set to true, will hide commands in the help output that have no desc (basically exposes what the hidden _doc command was already doing). Thanks @blackjid! See #170
  • Updated must_match documentation, see #163

v2.9.0

19 Jan 19:14
Compare
Choose a tag to compare
  • Synopsis can be shown in a more compact format for complex apps (See #160)
  • Full synopsis now shows flags and switches in the correct location on the command line (See #162)
  • Flags can now be made required and GLI will error if they are omitted (See #161)
  • Generated gemspec now uses git by default to get the file list (See #159, thanks to @JesseHerrick!)

Also, some documentation updates:

v2.8.1

19 Jan 19:07
Compare
Choose a tag to compare
  • Message printed when initconfig generates the config file (See #158, thanks to @calestar!)

v2.8.0

15 Sep 16:03
Compare
Choose a tag to compare
  • Fixes #154 courtesy @tokengeek and [@jonhl] allowing --help to work as one would expect with subcommands.

v2.7.0

06 Jul 16:38
Compare
Choose a tag to compare
  • Can now re-open commands later on, which can allow commands_from extensions. See #152 (which fixes #144 more or less). Thanks @jonhnl for the fix!
  • When a custom on_error block evaluates to false, and GLI_DEBUG is set, GLI will output a message explaining that custom error handling has been skipped. See #151
  • When a user requests help via --help on the command line, the exception used to make that work will not cause the on_error block to be called. See #150

v2.6.2

03 Jul 15:01
Compare
Choose a tag to compare
  • When the pre block returns a falsey value, it now does so via a special-purpose exception and also provides a message that the preconditions failed (see #146)
  • Previously, doing app --help command would execute command. Now, it acts the same as app help command, i.e. gets help for that command (see #149)

v2.6.1

02 Jul 19:33
Compare
Choose a tag to compare
  • Default values now being copied to aliases in options hashes (see #148)

v2.6.0

02 Jul 19:34
Compare
Choose a tag to compare
  • --version now just shows the version, courtesy [@brianknight10](see [138],[143])
  • Synopsis is now more honest - doesn't show [command options] if there aren't any, courtesy [@calestar](see [147])
  • A falsey exit from pre will now cause the app to exit nonzero (or with an exception if GLI_DEBUG is set), (see 146)
  • Support for terminal detection on solaris (see 129)

Biggest change is:

Redesign of how subcommands are handled to enable each subcommand to have its own space of arguments and options.

To enable this, you must subcommand_option_handling :normal

subcommand_option_handling :normal

This is inserted into new applications, but isn't the default for backwards compatibility.

Before

Subcommands can't use flags or switches the parent uses:

command :tasks do |c|
  c.flag :long

  c.command :list do |list|
    c.flag :long # <---- runtime error
    c.action do |*|
    end
  end
end

Subcommands can't use a flag/switch with the same name as another subcommand with the same parent:

command :tasks do |c|
  c.command :list do |list|
    c.flag :long
    c.action do |*|
    end
  end

  c.command :new do |new|
    c.flag :long # <----- runtime error
    c.action do |*|
    end
  end
end

After

Each subcommand has its own "flagspace":

command :tasks do |c|
  c.flag :long
  c.command :list do |list|
    c.flag :long
    c.action do |*|
    end
  end

  c.command :new do |new|
    c.flag :long # <----- runtime error
    c.action do |*|
    end
  end
end

You might do this:

> my_app tasks --long given-to-command list --long given-to-list-subcommand
> my_app tasks --long given-to-command new --long given-to-list-subcommand

The reason for an RC is that it required a fair amount of re-working of the code, so I want to be sure nothings subtle was broken.

Old behavior is the default: https://github.com/davetron5000/gli/blob/fully-nested-subcommands/lib/gli/app.rb#L262