# \[proposal\] dry-cli

**URL:** <https://discourse.dry-rb.org/t/proposal-dry-cli/377>\
**Category:** Ideas\
**Created:** [October 25, 2017, 3:03am UTC](https://discourse.dry-rb.org/t/proposal-dry-cli/377 "2017-10-25T03:03:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbacha](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/kbacha/32/107_2.png) [@kbacha](https://discourse.dry-rb.org/u/kbacha)\
**Post date:** [October 25, 2017, 3:03am UTC](https://discourse.dry-rb.org/t/proposal-dry-cli/377/1 "2017-10-25T03:03:32Z")

</div>

I’m working on a ruby CLI at the moment and I have been using thor:  
[http://whatisthor.com/](http://whatisthor.com/)

I’ve been toying with this idea for a little while but it seems like the model of dry-types and the coercion/constraints would play nicely into a CLI. To that end, I was wondering if this has been broached before, what status that might be at, and whether it’s something that might be considered in the future.

I feels like a simple interface could be something like (although obviously informal at this point)

```ruby
class CLI < Dry::CLI
   register_command 'action', Action, desc: 'Some textual description'
  
  class Action
    extend Dry::CLI::Command

    param :arg1, Types::String.enum('opt1', 'opt2'), desc: 'This is the first arg', default: -> { 'opt1' }
    param :arg2
    option :option1
  end
end 

```

The interface is similar to dry-initializer + dry-containers where the containers are initialized “verb” like objects. Of course, an extension is to include descriptions for rendering help text to the end user. I’m basically building this by simply passing the options hash from thor to a class right now, but having this interact more seamlessly between would be really nice.

---

<div class="post-metadata">

**Author:** ![gotar](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/gotar/32/8_2.png) [@gotar](https://discourse.dry-rb.org/u/gotar)\
**Post date:** [October 26, 2017, 6:54am UTC](https://discourse.dry-rb.org/t/proposal-dry-cli/377/2 "2017-10-26T06:54:57Z")

</div>

As I know Tim already start playing with CLI, for sure it will be used for ROM and dry-web, but not thor (why not you can read in article), but hanami cli: [https://github.com/hanami/cli](https://github.com/hanami/cli)

---

<div class="post-metadata">

**Author:** ![timriley](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/timriley/32/25_2.png) [@timriley](https://discourse.dry-rb.org/u/timriley)\
**Post date:** [October 26, 2017, 10:15am UTC](https://discourse.dry-rb.org/t/proposal-dry-cli/377/3 "2017-10-26T10:15:27Z")

</div>

Nice ideas, @kbacha, and definitely ones I’ve had before.

@gotar’s answer is pretty much on the mark: I’m currently early in the process of building a modular CLI for dry-{system,web,web-roda} and I’m basing it on top of hanami-cli. It does pretty much everything I would’ve wanted in a modern CLI library, so I’m using that.
