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 to Override Order of Commands in Help #642

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Copy edit the documentation
  • Loading branch information
rafaelfranca committed May 11, 2023
commit 60abf76b54b88e26f5c5a3c6e50c2563c1e82aac
13 changes: 2 additions & 11 deletions lib/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,22 +496,13 @@ def help(command = nil, subcommand = true); super; end
end
alias_method :subtask_help, :subcommand_help

# Sort the commands, lexicographically by default
# Sort the commands, lexicographically by default.
#
# Can be overridden in the subclass to change the display order of the
# commands, for example defining
#
# def self.sort_commands!(list)
# list.sort_by! do |a,b|
# a[0] == :help ? -1 : a[0] <=> b[0]
# end
# end
#
# will put the +help+ command at the top
# commands.
def sort_commands!(list)
defined?(super) ? super(list) : list.sort! { |a, b| a[0] <=> b[0] }
end

end

include Thor::Base
Expand Down