rails / thor

Thor is a toolkit for building powerful command-line interfaces.
http://whatisthor.com/
MIT License
5.11k stars 552 forks source link

Indentation issues result when more complicated option aliases are used #758

Open sereneiconoclast opened 2 years ago

sereneiconoclast commented 2 years ago

Demo (using Ruby 2.7.4):

require 'thor'

class MyThor < Thor
  default_command :go
  desc '', 'Do some stuff'
  long_desc <<~LONG_DESC
    Do some stuff.
  LONG_DESC

  option "verbose", desc: "verbose logging", aliases: %w(-v), type: :boolean
  option "debug", desc: "debug mode", type: :boolean

  # If this next option is commented out, the 'help' output lines them up nicely
  #
  # Options:
  #   -v, [--verbose], [--no-verbose]  # verbose logging
  #       [--debug], [--no-debug]      # debug mode
  #
  # If it is present, the indentation is uneven:
  #
  # Options:
  #   -v, [--verbose], [--no-verbose]                # verbose logging
  #           [--debug], [--no-debug]                # debug mode
  #   -p, --post-to-gh, [--post-to-github=USERNAME]  # post to a GitHub repository
  #
  # Preferred output:
  #
  # Options:
  #   -v, [--verbose], [--no-verbose]                           # verbose logging
  #       [--debug], [--no-debug]                               # debug mode
  #   -p, [--post-to-gh=USERNAME], [--post-to-github=USERNAME]  # post to a GitHub repository

  option "post-to-github", desc: "post to a GitHub repository", aliases: %w(-p --post-to-gh), banner: 'USERNAME'

  def go
    puts("Options: #{options.inspect}")
  end
end

MyThor.start(ARGV)

The options work as expected. It's only the "help go" output that has an issue.

Thanks!

dorner commented 2 years ago

Would be great to see a pull request fixing this! 😄