I’m working on a ruby CLI at the moment and I have been using thor:
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)
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.