commands: Deduplicate command print logic
This commit is contained in:
parent
3bbffdd1d7
commit
0b613d2fe3
@ -31,23 +31,18 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
ohai "Built-in commands", Formatter.columns(Commands.internal_commands)
|
[["Built-in commands", -> { Commands.internal_commands }],
|
||||||
puts
|
["Built-in developer commands", -> { Commands.internal_developer_commands }],
|
||||||
ohai "Built-in developer commands", Formatter.columns(Commands.internal_developer_commands)
|
["External commands", -> { Commands.external_commands }],
|
||||||
|
["Cask commands", -> { Commands.cask_internal_commands }],
|
||||||
external_commands = Commands.external_commands
|
["External cask commands", -> { Commands.cask_external_commands }]]
|
||||||
if external_commands.present?
|
.each_with_index do |title_and_proc, index|
|
||||||
puts
|
title, proc = title_and_proc
|
||||||
ohai "External commands", Formatter.columns(external_commands)
|
cmds = proc.call
|
||||||
end
|
if cmds.present?
|
||||||
|
puts unless index.zero?
|
||||||
puts
|
ohai title, Formatter.columns(cmds)
|
||||||
ohai "Cask commands", Formatter.columns(Commands.cask_internal_commands)
|
end
|
||||||
|
|
||||||
cask_external_commands = Commands.cask_external_commands
|
|
||||||
if cask_external_commands.present?
|
|
||||||
puts
|
|
||||||
ohai "External cask commands", Formatter.columns(cask_external_commands)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'cask/cmd'
|
require "cask/cmd"
|
||||||
|
|
||||||
module Commands
|
module Commands
|
||||||
module_function
|
module_function
|
||||||
@ -160,10 +160,7 @@ module Commands
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cask_external_commands
|
def cask_external_commands
|
||||||
tap_cmd_directories = Tap.cmd_directories
|
PATH.new(Tap.cmd_directories, ENV["HOMEBREW_PATH"]).flat_map do |search_path|
|
||||||
path = PATH.new(tap_cmd_directories, ENV["HOMEBREW_PATH"])
|
|
||||||
|
|
||||||
path.flat_map do |search_path|
|
|
||||||
find_commands(search_path).map do |possible_command|
|
find_commands(search_path).map do |possible_command|
|
||||||
p = possible_command.to_path
|
p = possible_command.to_path
|
||||||
command_name = p.match(/brewcask-(.*)\.rb/) { |data| data[1].delete_suffix(".rb") }
|
command_name = p.match(/brewcask-(.*)\.rb/) { |data| data[1].delete_suffix(".rb") }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user