Skip to content

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

@sereneiconoclast

Description

@sereneiconoclast

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions