Sha256: c23139fa4b2a80771db1872c18870fd5907814ed9f23becccb044bfbc25e11fd

Contents?: true

Size: 965 Bytes

Versions: 65

Compression:

Stored size: 965 Bytes

Contents

module GitStyleBinary
  module Commands
    class Help
      # not loving this syntax, but works for now
      GitStyleBinary.command do
        short_desc "get help for a specific command"
        run do |command|

          # this is slightly ugly b/c it has to muck around in the internals to
          # get information about commands other than itself. This isn't a
          # typical case
          def educate_about_command(name)
            load_all_commands
            if GitStyleBinary.known_commands.has_key?(name)
              cmd = GitStyleBinary.known_commands[name]
              cmd.process_parser!
              cmd.parser.educate
            else
              puts "Unknown command '#{name}'"
            end
          end

          if command.argv.size > 0
            command.argv.first == "help" ? educate : educate_about_command(command.argv.first)
          else
            educate
          end
        end
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 5 rubygems

Version Path
poolparty-1.3.7 vendor/gems/git-style-binaries/lib/git-style-binary/commands/help.rb
poolparty-1.3.6 vendor/gems/git-style-binaries/lib/git-style-binary/commands/help.rb
poolparty-1.3.4 vendor/gems/git-style-binaries/lib/git-style-binary/commands/help.rb
poolparty-1.3.3 vendor/gems/git-style-binaries/lib/git-style-binary/commands/help.rb
poolparty-1.3.1 vendor/gems/git-style-binaries/lib/git-style-binary/commands/help.rb