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
Show file tree
Hide file tree
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
There is no super method to check
Thor will not inherit from any other class, and the goal is to allow
subclasses to override the sort_commands! method, so we don't need to
check for super.
  • Loading branch information
rafaelfranca committed May 11, 2023
commit b2590c1e846fea038ca0c383c74718fac4dbd229
2 changes: 1 addition & 1 deletion lib/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def help(command = nil, subcommand = true); super; end
# Can be overridden in the subclass to change the display order of the
# commands.
def sort_commands!(list)
defined?(super) ? super(list) : list.sort! { |a, b| a[0] <=> b[0] }
list.sort! { |a, b| a[0] <=> b[0] }
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/sort_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ def self.sort_commands!(list)
expect(@content).to match(/:help.+:a.+:z/m)
end
end
end
end