# \[dry-cli\] Option for tab completion

**URL:** <https://discourse.dry-rb.org/t/dry-cli-option-for-tab-completion/1394>\
**Category:** Support\
**Created:** [December 4, 2021, 7:30pm UTC](https://discourse.dry-rb.org/t/dry-cli-option-for-tab-completion/1394 "2021-12-04T19:30:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![postmodern](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/postmodern/32/696_2.png) [@postmodern](https://discourse.dry-rb.org/u/postmodern)\
**Post date:** [December 17, 2021, 3:42am UTC](https://discourse.dry-rb.org/t/dry-cli-option-for-tab-completion/1394/2 "2021-12-17T03:42:14Z")

</div>

Because `dry-cli` using ruby’s `optparse` under the hood, and `OptionParser` does include [hidden options](https://github.com/ruby/optparse/blob/faf8e5c8fba85ae2dda8d9d882de4c7016b31ec5/lib/optparse.rb#L1007-L1027) for dumping out completion values, it should be possible to pass in these secret option flags to a `dry-cli` app:

```ruby
#!/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)

```

```auto
./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.

---

_[View the full topic](https://discourse.dry-rb.org/t/dry-cli-option-for-tab-completion/1394)._
