[dry-cli] Option for tab completion

Because dry-cli using ruby’s optparse under the hood, and OptionParser does include hidden options for dumping out completion values, it should be possible to pass in these secret option flags to a dry-cli app:

#!/usr/bin/env ruby

require 'optparse'

optparser = OptionParser.new do |opts|
  opts.banner = 'usage: test.rb [options]'

  opts.on('-t', '--test TEST', 'Sets @test') do |test|
    @test = test
  end

  opts.on('-o', '--opt [OPT]', 'Sets @opt') do |opt|
    @opt = opt
  end

  opts.on_head('-h', '--help', 'Prints this help') do
    puts opts
    exit
  end
end

argv = optparser.parse!(ARGV)
./test.rb --*-completion-bash=-
--help
-h
--test
-t
--opt
-o

Although, I haven’t seen an example of how to connect those hidden options to actual bash/zsh completion rules that would be loaded into your shell.