mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
caveats: combine completion and function messages
Fixes https://github.com/Homebrew/homebrew-core/issues/10338. Closes #2287. Signed-off-by: Alex Dunn <dunn.alex@gmail.com>
This commit is contained in:
parent
76955b47bd
commit
00af5250f0
@ -16,11 +16,9 @@ class Caveats
|
|||||||
f.build = build
|
f.build = build
|
||||||
end
|
end
|
||||||
caveats << keg_only_text
|
caveats << keg_only_text
|
||||||
caveats << bash_completion_caveats
|
caveats << function_completion_caveats(:bash)
|
||||||
caveats << zsh_completion_caveats
|
caveats << function_completion_caveats(:zsh)
|
||||||
caveats << fish_completion_caveats
|
caveats << function_completion_caveats(:fish)
|
||||||
caveats << zsh_function_caveats
|
|
||||||
caveats << fish_function_caveats
|
|
||||||
caveats << plist_caveats
|
caveats << plist_caveats
|
||||||
caveats << python_caveats
|
caveats << python_caveats
|
||||||
caveats << elisp_caveats
|
caveats << elisp_caveats
|
||||||
@ -72,56 +70,35 @@ class Caveats
|
|||||||
s << "\n"
|
s << "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def bash_completion_caveats
|
def function_completion_caveats(shell)
|
||||||
return unless keg
|
return unless keg
|
||||||
return unless keg.completion_installed?(:bash)
|
return unless which(shell.to_s)
|
||||||
|
|
||||||
<<-EOS.undent
|
completion_installed = keg.completion_installed?(shell)
|
||||||
Bash completion has been installed to:
|
functions_installed = keg.functions_installed?(shell)
|
||||||
#{HOMEBREW_PREFIX}/etc/bash_completion.d
|
return unless completion_installed || functions_installed
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
def zsh_completion_caveats
|
installed = []
|
||||||
return unless keg
|
installed << "completions" if completion_installed
|
||||||
return unless keg.completion_installed?(:zsh)
|
installed << "functions" if functions_installed
|
||||||
|
|
||||||
<<-EOS.undent
|
case shell
|
||||||
zsh completion has been installed to:
|
when :bash
|
||||||
#{HOMEBREW_PREFIX}/share/zsh/site-functions
|
<<-EOS.undent
|
||||||
EOS
|
Bash completion has been installed to:
|
||||||
end
|
#{HOMEBREW_PREFIX}/etc/bash_completion.d
|
||||||
|
EOS
|
||||||
def fish_completion_caveats
|
when :zsh
|
||||||
return unless keg
|
<<-EOS.undent
|
||||||
return unless keg.completion_installed?(:fish)
|
zsh #{installed.join(" and ")} have been installed to:
|
||||||
return unless which("fish")
|
#{HOMEBREW_PREFIX}/share/zsh/site-functions
|
||||||
|
EOS
|
||||||
<<-EOS.undent
|
when :fish
|
||||||
fish completion has been installed to:
|
fish_caveats = "fish #{installed.join(" and ")} have been installed to:"
|
||||||
#{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
|
fish_caveats << "\n #{HOMEBREW_PREFIX}/share/fish/vendor_completions.d" if completion_installed
|
||||||
EOS
|
fish_caveats << "\n #{HOMEBREW_PREFIX}/share/fish/vendor_functions.d" if functions_installed
|
||||||
end
|
fish_caveats
|
||||||
|
end
|
||||||
def zsh_function_caveats
|
|
||||||
return unless keg
|
|
||||||
return unless keg.zsh_functions_installed?
|
|
||||||
|
|
||||||
<<-EOS.undent
|
|
||||||
zsh functions have been installed to:
|
|
||||||
#{HOMEBREW_PREFIX}/share/zsh/site-functions
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
def fish_function_caveats
|
|
||||||
return unless keg
|
|
||||||
return unless keg.fish_functions_installed?
|
|
||||||
return unless which("fish")
|
|
||||||
|
|
||||||
<<-EOS.undent
|
|
||||||
fish functions have been installed to:
|
|
||||||
#{HOMEBREW_PREFIX}/share/fish/vendor_functions.d
|
|
||||||
EOS
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def python_caveats
|
def python_caveats
|
||||||
|
@ -302,23 +302,24 @@ class Keg
|
|||||||
dir = case shell
|
dir = case shell
|
||||||
when :bash then path.join("etc", "bash_completion.d")
|
when :bash then path.join("etc", "bash_completion.d")
|
||||||
when :zsh
|
when :zsh
|
||||||
dir = path.join("share", "zsh", "site-functions")
|
dir = path/"share/zsh/site-functions"
|
||||||
dir if dir && dir.directory? && dir.children.any? { |f| f.basename.to_s.start_with?("_") }
|
dir if dir.directory? && dir.children.any? { |f| f.basename.to_s.start_with?("_") }
|
||||||
when :fish then path.join("share", "fish", "vendor_completions.d")
|
when :fish then path/"share/fish/vendor_completions.d"
|
||||||
end
|
end
|
||||||
dir && dir.directory? && !dir.children.empty?
|
dir && dir.directory? && !dir.children.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def zsh_functions_installed?
|
def functions_installed?(shell)
|
||||||
# Check for non completion functions (i.e. files not started with an underscore),
|
case shell
|
||||||
# since those can be checked separately
|
when :fish
|
||||||
dir = path.join("share", "zsh", "site-functions")
|
dir = path/"share/fish/vendor_functions.d"
|
||||||
dir && dir.directory? && dir.children.any? { |f| !f.basename.to_s.start_with?("_") }
|
dir.directory? && !dir.children.empty?
|
||||||
end
|
when :zsh
|
||||||
|
# Check for non completion functions (i.e. files not started with an underscore),
|
||||||
def fish_functions_installed?
|
# since those can be checked separately
|
||||||
dir = path.join("share", "fish", "vendor_functions.d")
|
dir = path/"share/zsh/site-functions"
|
||||||
dir && dir.directory? && !dir.children.empty?
|
dir.directory? && dir.children.any? { |f| !f.basename.to_s.start_with?("_") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def plist_installed?
|
def plist_installed?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user