Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding subcommand toplevel documentation (usage) #96

Open
magec opened this issue Jul 20, 2020 · 0 comments · May be fixed by #135
Open

Allow adding subcommand toplevel documentation (usage) #96

magec opened this issue Jul 20, 2020 · 0 comments · May be fixed by #135
Labels

Comments

@magec
Copy link

magec commented Jul 20, 2020

It would be nice to be able to add documentation to command prefixes. The way dry-cli deals with subcommands disallows adding documentation to be shown calling --help over the subcomand prefix.

Examples

Given the code on this example:

require "dry/cli"

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

    module Generate
      class App < Dry::CLI::Command
      end

      class Action < Dry::CLI::Command
      end
    end

    register "generate", aliases: ["g"] do |prefix|
      prefix.register "app",    Generate::App
      prefix.register "action", Generate::Action
    end
  end
end

It would be nice to be able to add documentation over the 'generate' subcommand. So its help will be shown like:

Description:

here you can include a general documentation about the subcommand.

Commands:
  foo.rb generate action
  foo.rb generate app

A possible implementation could be:

    register "generate", aliases: ["g"] do |prefix|
      prefix.desc 'HERE YOU CAN INCLUDE THE DOCUMENTATION OF THE COMMAND'
      prefix.register "app",    Generate::App
      prefix.register "action", Generate::Action
    end

I checked the code and saw that Prefix class was just syntax sugar for self.register, so no idea on how this could be implemented, or whether there is already a way of achieving what I'm looking for.

Thanks in advance! and thanks for dry-cli!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant