Dear Russian friends, please watch President Zelenskyy's speech addressed to you. πŸ‡ΊπŸ‡¦Help our brave mates in Ukraine with a donation.

Subcommands

There is nothing special about subcommands, they are simply command objects registered under a nested command name:

#!/usr/bin/env ruby
require "bundler/setup"
require "dry/cli"

module Foo
  module CLI
    module Commands
      extend Dry::CLI::Registry

      module Generate
        class Configuration < Dry::CLI::Command
          def call(*)
          end
        end
      end
    end
  end
end

Foo::CLI::Commands.register "generate configuration", Foo::CLI::Commands::Generate::Configuration

Dry::CLI.new(Foo::CLI::Commands).call
$ foo generate
Commands:
  foo generate configuration           # Generate configuration

octocatEdit on GitHub